Don’t use the Genesis Blog Page Template

(Short answer: it’s not the main query, so customizations to the query won’t work. Make your blog the WordPress way, using Settings > Reading).

Genesis has been under development for quite a few years now. Given it’s history and large user base, there’s a few old features that would be removed, given the opportunity, but are needed for backwards compatibility – so people who have used them in the past can keep using them.

The biggest one (in my opinion) is the blog page template.

When you first install WordPress, your homepage lists your most recent blog posts. If you’d like a static homepage and to move your blog to a subpage, you can do so in Settings > Reading.

WordPress looks at specific files for these different pages. home.php is used for your blog posts listing (whether that’s your homepage or a subpage). front-page.php is used for the homepage of your site, whether you want blog posts or a static front page.

So, if you want a static homepage and your blog on a subpage like /blog, create the pages “Home” and “Blog”, go to Settings > Reading and set those as the appropriate pages to be used. If you’d like to create a template file to control the homepage, use front-page.php. If you’d like to create a template file to control the blog, use home.php.

Many of the older StudioPress child themes incorrectly use home.php for their static homepage. I’m not sure the reason, but my guess is they wanted to save people the step of going to Settings > Reading; when the theme was activated, the homepage was already a static homepage. The problem here is now you can’t have a blog. If you created a page and set it as the blog in Settings > Reading, it would use the home.php file which is now a static homepage.

Their solution to this was to create a page template that lists blog posts. The problem here is the blog posts are listed in a custom loop, not the main loop of the page (the main loop is the page’s content, which is replaced with this custom loop). This means plugins and other code that are designed to modify the main blog do not work.

What I recommend:
1. Never use the blog page template.
2. If you’re using a StudioPress theme that has home.php in it and it’s used for a static homepage, rename it to front-page.php. If you’re using one of the newer HTML5 themes, you should be fine. It’s only the older ones that have this issue
3. If you’re building a child theme for your client, exclude the Blog page template

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

  1. Jeremy says

    Thanks for this helpful post! Until now I had been using the blog page template for my posts, with a static homepage and the blog on a subpage.

    However, I also have been using a “trick” I read somewhere on the web, where I modified the following line in my child theme’s page_blog.php by adding the number 8 at the end of the line there:

    add_action(‘genesis_loop’, ‘genesis_standard_loop’, 8);

    This resulted in me being able to edit my blog page (the one using the blog page template) in the Visual Editor and add my own text there – eg. an H1 title etc – and the blog posts would be listed below whatever text I added to the page there. This makes it super easy to add a title and any other content I want at the top of the blog page, using the Visual Editor.

    If I instead use the method you’re recommending here, that means the above won’t work, and any content I’ve added to the blog page (which no longer uses the blog page template, and instead is set at Settings->Reading) will not appear on the front-end blog page. Right?

    Is there any way around this? I suppose the only solution would be for me to create my own customised home.php and put my content (H1 etc) in there? But that would mean not having the advantage of being able to easily edit the content using the Visual Editor.

    Second question: the Genesis “Theme Settings” page has a section called Blog Page Template, where I can set which category to display, which is very convenient. Your recommendation would make that setting unusable, right? Why is it there in the first place? Just for historical reasons? It’s a pity there isn’t a similar setting for setting the category to use, when using your recommended method here. What would you suggest?

    Thanks again!

    • Bill Erickson says

      If you want to add content to the top of the blog post listing, create a home.php file with this in it: https://gist.github.com/billerickson/9228933

      That will look at the blog page, grab what you typed in the page content area, and display it at the top. You could also hardcode the content in home.php, but this approach let’s you use the visual editor.

      Correct, the theme settings for the blog page template will not be used, since you’re not using the blog page template. But if you look at this post, you’ll see how to replicate it the “WordPress way”. Short answer (in functions.php): https://gist.github.com/billerickson/9228974

  2. Dave says

    Great Points, Bill.
    This is one of those points about WordPress that is confusing even to geeks. 🙂 The nomenclature of home.php and front-page.php is very vague, and just setting up any sort of homepage bollixes most beginners, which underscores the opaqueness of the admin interface before one gets used to it.

    Some site owners want a block of whatever text at the top of their blog page, sort of a newbie-ish “welcome to my site” thing. If the Genesis Blog template offered that, I could almost see keeping it around, but it doesn’t even do that.

    Best explanation I’ve seen yet!
    Thanks,
    Dave.

    • Bill Erickson says

      Yep, it’s really confusing. That’s the problem with 10 year old software that’s evolved a lot – some things weren’t named well in the beginning and have to stay that way for backwards compatibility.

  3. Jeremy says

    Thanks Bill! I have a couple of additional questions if you don’t mind:

    Firstly, regarding your function at https://gist.github.com/billerickson/9228974 how would I use this to include two or more categories? (Say I have several categories but just want two of them, or three of them, to be included on this page).

    Secondly, can I use category slug names or full (friendly) names with this function, instead of the cat number?

    Lastly, what is the recommended “WordPress way” to add a second, separate posts page that lists the posts from another category? Eg. let’s say I want to have two separate, independent blogs on my site – one blog page will list the posts from Category 1, and the other blog page will list the posts from Category 2. I can easily set up the first one using your method described here, via the home.php template and Settings -> Reading. But how would I then add the second blog page? I guess WordPress doesn’t support this setup natively? What would you recommend?

    Thanks again for your help!

    • Bill Erickson says

      Refer to the WP Query Codex for all the available parameters.

      To include three categories by slug, you’d use this: https://gist.github.com/billerickson/9253556

      For your second question, I’d say the “WordPress way” would be to use the category archives. So in Settings > Reading, do not specify a blog (so there’s no page that lists posts from cat 1 and 2).

      Then your first blog is yoursite.com/category/cat-1 and the other one is yoursite.com/category/cat-2

      In Settings > Permalinks, you could rename the category slug to be something other than category if you like.

      • Jeremy says

        Hi Bill, I’m having trouble with the function you posted for me here. Specifically, the array doesn’t seem to work. When I replace your “cat-1”, “cat-2” etc with my actual category slug names, the webpage (front end) puts “Sorry, no content matched your criteria” onto the page.

        If I remove the array and just put the function like this, it works fine – obviously only showing one category though:

        $query->set( ‘category_name’, ‘cat-1’ );

        Do you have any idea why it doesn’t work when I use an array? Is there a syntax error in your Gist perhaps?

        With the second question – about having two separate blog pages – I guess your suggestion of using category archives would mean I couldn’t use the method you provided here to add content to the top of the blog post listing, right? That “trick” would only work when one blog page was being used on the site, via the home.php template?

        Thanks for your help!

        • Bill Erickson says

          It looks like ‘category_name’ only accepts one category, not multiple. If you’re willing to use ID’s, you can use ‘category__in’ which will show posts in one OR the other, or you can use ‘category__and’ for posts in one AND the other.

          Or if you must use slugs, use a taxonomy query: https://gist.github.com/billerickson/9395154

          This is untested, I just wrote it in the browser. For further issues with queries, refer to the WordPress Codex: http://codex.wordpress.org/Class_Reference/WP_Query

          If you’re using Genesis, it provides a category intro title and description fields. Go to Posts > Categories and edit a category. This is actually one of the benefits of using a category rather than a post type archive (the main blog or another post type). Categories and tags already have an intro area.

  4. John says

    Great posts. I believe I have ran into some issues trying to customize the blog when using the Genesis loop so this is great stuff.

    I believe that the Gensis filters to change post-meta etc will still work even using the WordPress loop. Correct?

    Thanks!

  5. Chris says

    Hi Bill,

    Really good explanation and comments. I’ve always struggled with doing things the Genesis way and knowing it wasn’t how WordPress designed it to be.

    Would you ever see a reason to use the Blog page template for a secondary “blog”. Ie if you have a blog but also want a /news/ page (I’m thinking large corporate sites). I’d normally setup a blog page and a news page with the blog page template and set each to the corresponding category.

    Chris

    • Bill Erickson says

      You could use it for that purpose, but I’d just use the category archive.

  6. Massimo Chieruzzi says

    Thanks Bill, you saved me ! I had my blog page configured as a sub page of my site on /blog … I was trying to edit the loop editing the blog template included in my studipress template named page_blog but whatever I did nothing happened!
    Reading your post I understood that wordpress didn’t care about the page template attributed to that page and I had to create home.php !

  7. Jon Brown says

    I remember talking to you about this a while ago and it really helped me unconfuse me. Glad you got around to writing a blog post on it. Thanks again!

    The way I think about it now is if one is not using the main latest blog post query anywhere on the page, one shouldn’t be using home.php. Just saying “blog posts” can be a little confusing since many Genesis themes use featured posts widgets (no main query) or widgets in combination with the main query (slider widget / standard loop)

  8. Jeremy says

    One further question, Bill: my Genesis folder (at /wp-content/themes/genesis) doesn’t actually contain a file called “front-page.php” in the first place. Nor does my child theme folder. Why would that be? Your article here says that “front-page.php” is used for the homepage, and you’re describing a Genesis environment, so why doesn’t Genesis have this file?

    • Bill Erickson says

      There’s two reasons for this.

      The simple answer is the template hierarchy. WordPress looks for a specific template, and if that doesn’t exist it goes for a more general template. For instance, your “dog” category would first look for category-dog.php, then category.php, then archive.php, then index.php.

      The more complicated answer is that all the template files in Genesis just have the genesis() function, so they’re all the same. The difference is the functions that are hooked into the different Genesis hooks. For instance, if you open index.php and single.php, you’ll see they are exactly the same. But if you look in /lib/structure/post.php, you can see each bit of the template has conditional tags to specify what shows up where (look at genesis_do_post_content() as a good example).

      Right now your theme is using the index.php file from /genesis. If you put index.php in your child theme, that will take the priority because it is in the child theme. If you put front-page.php in your child theme, that will take the priority because it is more specific and in the child theme.

  9. Amanda says

    Hi Bill,

    I’m not a coder…so apologies if this is a silly question. I changed my blog page as per your post. The only thing is that I had a conditional statement to move the entry title to the ‘genesis_before_content_sidebar_wrap’ for all pages which does not work on the blog page anymore. I can see that the body class has changed to “blog”, but I don’t what conditional statement to use to specify the condition for the blog page.

    Thank you kindly for any assistance
    Amanda

    • Bill Erickson says

      I assume you have something like this in your theme: if ( is_page() ) { do something; }

      Change it to this: if( is_page() || is_home() ) { do something; }

  10. Mark Fayard says

    I’m using Cobalt Apps Dynamik child theme. By default it doesn’t permit you to select static pages for home or blog. Doing so “breaks” the EZ Home template. Any thoughts?

    • Bill Erickson says

      I would speak to the developers of that theme about it. They should support core WordPress features out of the box.

    • Jeremy says

      HI Mark, that’s not really correct. I’m also using Dynamik, and it definitely supports using a standard WordPress static page for the home and blog pages, ie. which you can set using the regular WordPress way via Settings -> Reading. In fact I use exactly this configuration myself.

      To accomplish this, all you need to do is go to the Dynamik Design Options page, then to the ‘EZ’ tab there, and select “WordPress Default Homepage”. Then you can go to Settings -> Reading, and change that to “A static page”, and select the page you want to use for the Front Page and for the Posts Page. And that’s it! 🙂