Archive Post Displays

In themes with Theme Blvd Framework 2.5+, you’ve already got user options for adjusting how posts display in your WordPress archives. This includes displaying posts as a blog, list, grid, or showcase; these are the standard displays within the framework. In this article, we’ll cover where those options are. And in addition to that, we’ll discuss how to handle adjusting the post displays for custom post type archives, from your child theme.

From Theme Options

If you’re digging into how your WordPress post archives are displaying, you might be looking to make a child theme customization, not realizing you actually have user options for this.

All Post Archives

From Appearance > Theme Options > Content > Archives, you can choose which post display will be applied to all post archives. This setting will be then be the default for all post archives, no matter the post type.

Individual Category and Tag Archives

Digging further, this is actually a bit of a hidden set of options, not a lot of people are aware of. If you click to edit a standard post category or tag, the framework has added some options for how that individual post archive will display. These settings pages can be accessed by going to Posts > Categories and Posts > Tags in your WordPress admin.

Custom Post Type Archives

Now that you know about the user options available to you, we can address a common question I get in support.

How do I change the post display for my custom post type archives?

This does requires child theme customization, but can easily be done in the same basic way our portfolios plugin adjusts all portfolio item archives to use a custom post display.

To do this, you’ll filter themeblvd_theme_mode_override, and if it’s an archive you want to target, return your custom post display as a string — blog, list, grid, or showcase.

One thing to note about the filter is that it’s applied by the framework in a function that is hooked to WordPress’s pre_get_posts. So, we’ll want to pass in the current query to our callback function, to utilize for our conditional functions, checking for our custom post type and taxonomy archives. — If that’s confusing, don’t worry; just make sure to use my example code below as your starting point.

Example

So as an example, let’s say we’ve registered a custom post type book, and associated taxonomies, author and genre. Now, in the following scenarios we want posts to display as a grid, instead of the default post display selected at Appearance > Theme Options > Content > Archives.

  1. Post archives, displaying all book posts.
  2. Taxonomy archives for author taxonomy, displaying book posts by author.
  3. Taxonomy archives for genre taxonomy, displaying book posts by genre.

And so here’s how we’d do it!

/**
 * Display book archives as a post grid.
 */
function my_theme_mode_override( $mode, $q ) {

    if ( $q->is_post_type_archive('book') || $q->is_tax('author') || $q->is_tax('genre') ) {
        $mode = 'grid';
    }

    return $mode;
}
add_filter('themeblvd_theme_mode_override', 'my_theme_mode_override', 10, 2 );