Community Forums › Forums › Archived Forums › Design Tips and Tricks › Generate Theme: Set Home Page to Specific Post Category
Tagged: generate, home, Static Page
- This topic has 7 replies, 3 voices, and was last updated 11 years, 2 months ago by David Chu.
-
AuthorPosts
-
July 30, 2013 at 10:11 am #53214skibob1027Member
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.comJuly 30, 2013 at 10:59 am #53219David ChuParticipantHi,
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:
function child_grid_loop_helper() {
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!!)
query_posts ($query_string . '&cat=3');
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
July 30, 2013 at 11:41 pm #53324ahuffordMemberThis 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?
July 31, 2013 at 7:47 am #53378David ChuParticipantHi,
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:
category__in
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
August 1, 2013 at 10:42 am #53572skibob1027MemberDavid, 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!
August 1, 2013 at 11:14 am #53582David ChuParticipantGreat! 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
August 1, 2013 at 5:57 pm #53632skibob1027MemberDavid, 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.
August 1, 2013 at 8:35 pm #53666David ChuParticipantBob,
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
-
AuthorPosts
- The topic ‘Generate Theme: Set Home Page to Specific Post Category’ is closed to new replies.