I wish this was part of Genesis.

I wish this was part of Genesis.

One of the neato things that I really like about the Genesis Framework from StudioPress (affiliate link) is that it comes with a couple different templates that I (or you) might find useful. The default template is what I use most often, but my second favorite template is the Blog Template. The obvious and easiest thing to do with it is to create a blog or news page, at which point it displays your most recent posts (which gets a little confusing, because it’s a page that just shows posts). You know, like a blog. For quite a few of us, that’s all we need, and once you set up the page, you never come back to it.

However, it’s possible to finesse the use of this a little bit by making a blog page for a specific category (or categories). Sometimes I just use this so I can show posts from a category without the link showing category/name-of-category/ (because who needs that?). I can also use it to set up a page that pulls posts from more than one category, which can come in handy.

Now, my issue is this: if I use the blog template on a page, it works excellently well for displaying the posts, but if I want to add introductory content to explain the category, it won’t show. If I skip the blog page and just use the category link that I don’t like, I can go into my categories and give them descriptions and SEO friendly titles (but what if I want a picture? or a form? and my clients may not remember to change the category info either), and I should do that anyway, but usually I would rather have that page, and get the best of both worlds: my content AND my posts.

Happily, Genesis allows me to do that, if I copy the page_blog.php file from the core Genesis folder, add it to my own theme folder, and add this line:

add_action( 'genesis_loop', 'genesis_standard_loop', 5 );

It has to be before the line that says genesis();, but that’s it. Now, whatever I put into the page content shows above the most recent posts.

Genesis Blog Template Magic
SM2 FISH info and news (click to enlarge)
One example of where I want this: the SM2 student ministry has a big annual event called FISH. On their site, they have a page describing what it is, and then when it’s coming up or actually happening, there are news posts (registration, info, pictures). Without this trick above, the page and the posts are totally disconnected, and the page has to have a link to each of the posts (“click here to register!” “click here for the schedule!”), which gets old. With this trick, I have one page that has all of the FISH event information in one place, with a super easy link.

I just finished a project with custom post types, and this trick solved a myriad of problems for me there, too. Since it’s one I use all the time, I thought I’d share–I know others need it, too. I am planning to share some of the lessons I learned in the process–namely, don’t make your job harder than it really is.

Since I do use this all the time, and I know I’m not the only one, I’ve actually asked StudioPress to make it standard. Hope they do, but if they don’t, it’s an easy fix.

Do something awesome. Tell a friend:

subscribe by email

If you're an email kind of person, that's totally cool. Go ahead and sign up here to get the latest blog entries in your inbox! No worries, I never share your address.
  • This field is for validation purposes and should be left unchanged.

Reader Interactions

Comments

  1. August 16, 2013

    Wow! This is a great bit of advice. I ran into the same issue and this snippet of code added the titles above my many category posts I have directed to pages. Very useful!

    Thanks much!

    Trev

  2. January 14, 2014

    This is great! I like the content appearing before my blog posts too, but I don’t want the page title to appear. Any ideas on how I get rid of the page titles but leave the post titles intact?

    • January 14, 2014

      That’s an interesting question and took a bit of digging. Turns out you can’t use the standard loop code, but you can do some surgery and use the content part of it. I posted a revised blog template as a gist if you want to use it (it’s for HTML5; you would have to do some research to find the XHTML version, but should be pretty straightforward).

        • June 26, 2016

          Is the Genesis Title Toggle screen reader friendly? Meaning is it accessible? I’m curious because when I tried testing with the Title Toggle checked to hide the title, the WAVE Web Accessibility tool indicates my H1 tag is missing.

          When I uncheck the Title Toggle to unhide the title, the WAVE Web Accessibility tool indicates my H1 tag is present.

          I love your site by the way. I just came across it today and have been finding tidbits highly useful.

          Mark

          • June 26, 2016

            It looks like the Title Toggle plugin removes the title altogether, so then yes, there is no `h1` left on the page unless you take steps to make one. To manage accessibility, the plugin would have to hide the title, but leave it visible to screen readers, as I understand it. It’s worth asking the developer about it on the forums, although I think it would require a fair amount of change in how the plugin manages the output, which may or may not be feasible.

            Thanks for the kind words!

          • June 30, 2016

            Okay, makes sense. I’ll swing by the forum and give them a heads up. I’m sure it’s a pain in the code to fix this issue. At least giving them a heads up will get them one awareness step closer to a solution.

  3. February 7, 2014

    Hi and thank you for this, I followed your instructions and it’s perfect — just one detail or question – how do you suggest I limit the posts to those from one category only? I have a few different spots where I could use this but only want the posts from one category to show up.

    • February 8, 2014

      Helen, great question–I know you’ve sorted this already but I’ll reply anyway so it’s here for others. You’ll want to add a custom field with a name of query_args and a value of cat=xx, where xx is the number value WordPress has assigned to your category (you can see this by editing the category and finding the number in the address bar).

    • February 8, 2014

      As long as you have added that line of code and uploaded the new page_blog.php file to your child theme, it should work regardless of whether you’re showing posts from all categories or just one. You’ll want to make sure that you haven’t removed the description, template, etc. lines from the original file, or else WordPress will not see it as an available template to use.

  4. April 7, 2014

    Your strategy worked perfect. But is there a way to have a full width before the normal design? For example, in this blog: http://www.zillow.com/blog/ there is a full width that display a slider then you see the excerpt area to the left and then the widgets to the right. Is there a way to do that? I mean to have the full width before everything.

    Thanks for the help

    • April 8, 2014

      Hey John! There are a couple of ways to accomplish that. I would create a new widget area and hook it into the genesis_before_content_sidebar_wrap hook. You can see other possible hooks on the Visual Hook Guide. Hope that helps!

  5. August 2, 2014

    Hi Robin, this is a great solution to allow a static header on a blog page. One issue though in comparison to using a straight category page is that I can’t get sorting by a custom field to work in this mode. I have a category of posts called ‘seminars’ (category #31) to list the upcoming talks by visiting professors at my school. Each seminar announcement is a different post. Since the date of the professor’s visit is different than the date I post the information, I want to have the seminar announcements sorted by the actual seminar date. So, I created a custom field in the posts called ‘SeminarDate-MMDDYYYY’ to hold that value. In the functions.php, this code sorts the posts correctly if I use a category page:

    function seminar_query_posts(){
    if(is_category(’31’) ) {
    $today = date(‘Ymd’);
    global $wp_query;
    $args = array_merge( $wp_query->query, array(
    ‘posts_per_page’ => 10,
    ‘meta_key’ => ‘SeminarDate-MMDDYYYY’ ,
    ‘orderby’ => ‘meta_value’,
    ‘order’=>’ASC’
    ) );
    query_posts( $args );
    echo $today;
    }
    }

    add_action(‘genesis_before_content’, ‘seminar_query_posts’);

    However, when I switch over to the hybrid page+posts method that you have detailed above, this no longer works. Any thoughts about what I would need to do to restore the sorting by custom field functionality?

    Thanks so much, you are awesome!

    • August 2, 2014

      Hey Sam, thanks for your comment! I am actually not really using this setup anymore–trying to push over to utilizing the built in archive and category pages. However, if you want to do this, you need to change your conditional in your function–since you’re not using the category page, the is_category( '31' ) won’t happen on your blog template page, and therefore your action can’t run. In case someone does access the category page, you can keep that conditional in, but modify it to be if ( is_category( '31' ) || is_page( 'xx' ), where xx is the ID of the page you’re using as a blog template. The || will allow the action to fire on either the category page or the page on which you’re using the blog template. Hope that helps!

      • August 2, 2014

        Thanks for your help, I really appreciate it. I changed the code and verified that statement is being executed inside the new conditional on the blog page. Unfortunately, it still is not changing the order to sort by the custom field. I even tried raising the priority and that didn’t do the trick either. Maybe something else in the executive-pro child theme or genesis structure is preventing the override?

        I may just switch to a category page as a quick solution. You mentioned a switch to the built in category pages…is there a way to achieve the static “page-like’ content on a post category page? I have been reluctant to just make links to the category from the menus because then I can’t use features of pages like “featured” images as such.

        Still struggling a bit as a beginner to modify the child themes effectively.

        • August 2, 2014

          Hmmm…looking into Genesis core and dusting off my brain cells, I think you want to modify what you’re doing just a hair. If you check loops.php in Genesis, the basis for what you want to accomplish is in the section starting at line 14. If you copy out the genesis_do_loop function and put your arguments in there, with the different conditionals, that might be better. The Codex also seems to warn against using query_posts, so using wp_parse_args (as Genesis core does) may give you better results.

          Also, you can add any content you want to a category/taxonomy page, as an introduction/description. It doesn’t have a WYSIWYG editor so you would have to do everything by hand, but depending on your requirements, that may not be problematic.

  6. January 8, 2016

    thanks so much, it was exactly what i was searching for, now i have the content page above my list posts.

  7. January 25, 2016

    Oh my gosh, thank you for this! I’ve been working with a client who wants to make some really crazy customizations to their blog post template above the posts list – this is exactly the functions loop snippet we needed to make it work. Thanks a mill!

    • May 25, 2016

      If it’s the Holden Beach link, it looks like you’re not using the blog template on that page–that’s what this is really meant for. Depending on what code is in your custom template for that page, this may not be what you’re wanting.

  8. July 19, 2018

    Thanks Robin, I’ve followed your instructions but so far no result. I wonder if there’s an extra layer of awkwardness introduced by Dynamik? Are you familiar with Dynamik?They have their own method for protecting child files from being overwritten that requires them to be placed in a special folder. I wonder if that’s the problem? I’d be grateful for any thoughts as Genesis and Dynamik are new to me and I find their little ways very confusing after years of simply creating child themes from core wordpress themes (twentytwelve was my fave).

    Reply

    • July 19, 2018

      Hey Kevin, I’m honestly not sure on this. I’ve never used Dynamik, but if they have their own ways of doing things, then you may very well be correct on this. It’s worth checking with their support or forums on how to accomplish this with their process.

  9. July 20, 2018

    I’ve tried it with the genesis-sample child theme and it works fine, (of course!). I’ve asked the Dynamik developers and I’ll let you know how it plays out, as a lot of people use Dynamik.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Bars Code Check chevron-down chevron-left chevron-right chevron-up Envelope Laptop Search Times Facebook GitHub Google Plus Instagram LinkedIn Pinterest Twitter WordPress Logo Wordpress Simple