Generate Theme: Set Home Page to Specific Post Category

Community Forums Forums Design Tips and Tricks Generate Theme: Set Home Page to Specific Post Category

This topic is: resolved

This topic contains 7 replies, has 3 voices, and was last updated by  David Chu 1 year, 4 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #53214

    skibob1027
    Participant
    Post count: 6

    I’m new to Genesis, so please pardon my ignorance in how to make this work. I’ve tried searching the forums and reading documentation, but I’m just not “getting it”.

    I’m using the generate theme, but would like to replace the rolling series of posts with static content. My thought was that I can create a single post assigned to the “Home” category that will show up in place of the running list of most recent posts in the standard theme. Additionally, I would like to use a specific widget sidebar for the home page instead of the primary widget sidebar that is used on all other pages.

    Here are the two basic questions:

    • How can I edit home.php to show a specific post or post category instead of the six most recent posts?
    • How can I set the home page to use a different widget sidebar in lieu of the primary widget sidebar?

    Thanks!

    http://www.steibelsauto.com
    #53219

    David Chu
    Participant
    Post count: 1426

    Hi,
    That’s actually a fairly advanced question, so don’t feel too bad! My answer is actually a general WordPress answer, not specifically for Genesis. What you do is “intercept” the loop slightly. You’ll need to be comfortable editing code.

    First, go to Posts…. Categories. Find the Category you want (you said “Home” in your question), and hover your mouse over its link. Somewhere on your screen, a link should appear that’s very long, and you’ll be looking in the link for something like “tag_ID=3″. You’ll want to make a note of the number.

    Now comes the editing. Appearance…. Editor. Look to the right, and find “home.php”. Click on that. If you’re nervous, copy the code from that and save it. :-) You’ll also want to have FTP access to the site in case you make a typo that stops your site from working.

    You’ll see this line in there:
    [php]
    function child_grid_loop_helper() {
    [/php]

    Just below that, you can add this line, changing the “3” to the number you saved above. (make sure it’s on its own line!!)

    [php]
    query_posts ($query_string . ‘&cat=3′);
    [/php]

    This preps the loop to only show that particular Category. If it all works, save your code somewhere in case you or the client inadvertently update Generate and blow away your addition.

    Good luck,
    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #53324

    ahufford
    Participant
    Post count: 2

    This is very helpful information. I was looking to do the same thing. However, I’ve disabled home.php because I couldn’t get the formatting to show up in my excerpts (was using the grid, now I am not). Is there a way to add this code — query_posts ($query_string . ‘&cat=3′); — to functions.php and have it just apply to the home page?

    #53378

    David Chu
    Participant
    Post count: 1426

    Hi,
    Ah, someone after my own heart…. doing as much as possible in functions instead of template files. ;)

    Yes, you could do that. I would suggest going here for an example:

    http://genesissnippets.com/genesis-custom-loop/

    … and one could use this instead of category_not_in, for instance:

    [php]
    category__in
    [/php]

    And then you could is_home() or is_front_page() logic, depending on context, to have it only work on Home.

    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #53572

    skibob1027
    Participant
    Post count: 6

    David, thank you very much for your help! The solution was exactly what I was looking for. I’m still having trouble setting the home page to use a different widget sidebar in lieu of the primary widget sidebar. Do you have any thoughts as to how I can accomplish that goal?

    Thanks!

    #53582

    David Chu
    Participant
    Post count: 1426

    Great! You could hire me to code it. ;)

    But I’m thinking that Genesis Simple Sidebars plugin may work for that. I have a designer partner who is Sidebar Crazy, and she uses that ad infinitum. One site we did had something like 50 different sidebars. Oy vay! :-)

    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #53632

    skibob1027
    Participant
    Post count: 6

    David, you sir, are awesome. I think I can handle this one, but I’m bookmarking your site for complex help in future projects. I speak PHP as a “second language”, so to speak, but haven’t completely figured out how Genesis works within WordPress.

    #53666

    David Chu
    Participant
    Post count: 1426

    Bob,
    I appreciate the positive thoughts, thanks! I’m glad that helped.

    It’s true, WordPress knowledge is one thing, and Genesis is another (albeit smaller). The good news is that once you’ve done Genesis for awhile, WordPress development becomes easier. I see themes with 20+ template files, and most of my custom child themes have a whopping 2! ;-)

    Talk to you later,
    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Generate Theme: Set Home Page to Specific Post Category’ is closed to new replies.