Community Forums › Forums › Archived Forums › Design Tips and Tricks › Show full posts for specific category?
- This topic has 7 replies, 3 voices, and was last updated 9 years, 1 month ago by Tonya.
-
AuthorPosts
-
March 12, 2015 at 2:17 am #144130BirmingMember
I'm trying to have one category to show full posts, just as they would look on a single page.
This is where I am right now, but it displays as "Show Content", ignoring line breaks:
add_action('genesis_post_content', 'add_genesis_post_content'); function add_genesis_post_content() { if ( is_category( '506' ) ) remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); add_action( 'genesis_entry_content', 'the_content' ); }
How should the code look for the posts to display fully?
Thanks in advance!
Robert Birming
MittpunktMarch 12, 2015 at 4:32 am #144141TonyaMemberHello Robert,
You can achieve this fairly easily. If you look in genesis/lib/structure/post.php and go to about line 303 you find the genesis_do_post_content() function. This function handles how the content is rendered (displayed out to the browser). If all you want to do is show the full posts on the Category 506 archive page, then here is a snippet to help you out:
add_action( 'genesis_entry_content', 'tonya_do_post_content' ); add_action( 'genesis_post_content', 'tonya_do_post_content' ); /** * Show the full content vs. excerpt for specific category * * @since 1.0.0 * * @uses genesis_do_post_content() * * @return void */ function tonya_do_post_content() { //* If this is category 506, then override the settings & just render //* out the full content. if ( is_category( 506 ) ) { the_content( __( '[Read more...]', 'genesis' ) ); } //* Otherwise, call the standard Genesis function & let it handle the output else { genesis_do_post_content(); } }
So basically, if it is the right category you are targeting, then call the_content() which outputs the full post; else call Genesis and let it handle it.
Cheers,
Tonya
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer BootcampMarch 12, 2015 at 8:32 am #144166Brad DaltonParticipantMarch 12, 2015 at 12:06 pm #144212TonyaMemberThanks, Brad!
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer BootcampMarch 12, 2015 at 12:44 pm #144214BirmingMemberThank you very much, Tonya, much appreciated!
One thing, though. Now the other categories display the preview content twice, no matter if I chose "Display post content" or "Display post excerpts" in the Genesis theme settings.
Any idea how to fix this? Thanks in advance!
Cheers,
Robert
Robert Birming
MittpunktMarch 12, 2015 at 1:33 pm #144221TonyaMemberHey Robert,
And it would because I forgot to tell you to do add this too:
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_post_content', 'genesis_do_post_content' );
Sorry about that.
So you are removing the genesis_do_post_content() function from the hook and replacing it with tonya_do_post_content() or whatever you call it in your site.
Cheers,
Tonya
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer BootcampMarch 12, 2015 at 2:13 pm #144225BirmingMemberMarch 12, 2015 at 2:15 pm #144227TonyaMemberYou are very welcome, Robert. Please do me a favor and mark this topic as "Resolved", as it helps us navigate open issues.
Enjoy the rest of your week!
Cheers,
Tonya
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer Bootcamp -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.