Community Forums › Forums › Archived Forums › Design Tips and Tricks › Custom Loop for Blog page – not working
Tagged: blog, custom loop, custom template, genesis
- This topic has 9 replies, 2 voices, and was last updated 8 years, 7 months ago by
JamesRoberts.
-
AuthorPosts
-
October 29, 2014 at 1:54 pm #129788
GregThrive
MemberHello all, hoping someone here can pick out what I'm doing incorrectly. I contacted StudioPress directly but they just gave a generic answer which was most unhelpful.
OS: Any
Browser: AnyI'm trying to create a custom blog template:
What i've done:
1. Created a template file out of the wordpress naming hierarchy
2. Created a custom loop based on genesis_standard_loop inserted into
template3. remove_action( 'genesis_loop', 'genesis_do_loop' ); and/or remove_action( 'genesis_loop', 'genesis_standard_loop' );
4. add_action( 'genesis_loop', 'custom_blog_loop' );
5. Created page, arbitrarily named (but want it named Blog)
6. Selected custom template on page
At this stage, if you load the page you can see the WYSIWYG content and
some test code i placed within the custom blog loop showing. No blog posts
are pulled in because it's just a page with no idea where blogs are...7. Under WordPress settings: Reading - set Posts page to my arbitrarily named Blog Page.
At this stage, the template no longer has any effect and the page is displaying the default blog loop from Genesis framework (genesis_standard_loop).
How do I set my custom page to the Posts Page while using a custom loop in a custom template?
Thanks for any assistance!
http://localOctober 29, 2014 at 2:08 pm #129789JamesRoberts
MemberHi Greg,
Just so I understand completely, you are trying to create a custom page template that you would like to use as your blog page, is that correct?
Is this blog page going to be styled differently than the other archive pages? If not then you may be better off creating a custom archive page rather than a page template.
Would it be possible to show the code you have running in your custom loop function?
Need beautiful and responsive Genesis child themes at amazing prices? Stop by LlamaPress and check out our themes.
October 29, 2014 at 2:24 pm #129793GregThrive
MemberJames,
Just so I understand completely, you are trying to create a custom page template that you would like to use as your blog page, is that correct?
Yes that's correct. More specifically I'd like to set my default blog category to 'blog', add '/%category%/' to my permalinks and create a custom Blog page (I want to leverage some functionality of it being a page). Ideally all archives and the blog page will share common markup, but I haven't gotten that far yet. I need custom markup outside of what the standard Genesis loop offers.
My custom loop function is a carbon copy of the genesis_standard_loop with a simple addition of an H1 for now to test that it is infact the loop being displayed. No other changes have been made.
October 29, 2014 at 2:37 pm #129794JamesRoberts
MemberHumm, if you replace the code in your custom loop with the following, do you see any blog posts?
if ( have_posts() ) : while ( have_posts() ) : the_post(); echo "<h2>" . get_the_title() . "</h2>"; endwhile; endif;
Need beautiful and responsive Genesis child themes at amazing prices? Stop by LlamaPress and check out our themes.
October 29, 2014 at 3:19 pm #129804GregThrive
MemberThe template is not being read once the page has been set to Posts Page under Settings -> Reading.
Once that page has been set as the blog page, nothing in the template has any affect. So the above code, or any code at all on the template or any markup of any kind is not working.
When "X" page is set as the blog page Genesis Standard Loop takes over. I have no idea why, this is my first Genesis site.
Note that I have other custom template with custom loops that work fine, it's something about setting the Posts Page in WordPress that blows this up.
October 29, 2014 at 3:21 pm #129805GregThrive
MemberOctober 29, 2014 at 3:39 pm #129809JamesRoberts
MemberI see. I beleive WordPress will ignore the page template for any page that is set to the posts page. It might be worth you trying this https://wordpress.org/plugins/posts-page-custom-template/, note I have not tried that myself but reading the description it seems to allow you to set page templates to the post page.
Need beautiful and responsive Genesis child themes at amazing prices? Stop by LlamaPress and check out our themes.
October 29, 2014 at 3:59 pm #129810GregThrive
MemberAh yeah, you are correct. Though if I named the template home.php that should work or so I thought...
October 29, 2014 at 4:09 pm #129812GregThrive
MemberWell home.php didn't work for whatever reason. Which is what I had originally set the template name as from memory but then scrapped it when it wasn't working!
However, thanks to you refreshing my memory on the template naming I named the template index.php and now it gets picked up properly.
I had to add
remove_action( 'genesis_loop', 'genesis_do_loop' ); vs.
remove_action( 'genesis_loop', 'genesis_standard_loop' );But hey, it's working as I wanted now! Thanks for your help!
October 29, 2014 at 4:11 pm #129814JamesRoberts
MemberGreat, no problem Greg, glad it is working 🙂
Need beautiful and responsive Genesis child themes at amazing prices? Stop by LlamaPress and check out our themes.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.