Community Forums › Forums › Archived Forums › General Discussion › How to show full text of the first post?
- This topic has 10 replies, 2 voices, and was last updated 10 years, 7 months ago by
Genesis Developer.
-
AuthorPosts
-
September 2, 2014 at 9:29 am #122419
korg007
MemberHi all,
I have a site with the max characters in posts for the blog list set to show... equal to 200. I did this because I want to automatically limit the amount of text show in the blogs on the blog list.However, as a first post, I have a "sticky" post for which I want the entire text to show. I don't want a "readmore" link on the blog list page for this post.
How can I override the character limit for this single post? or... is there another approach?
Thanks!September 2, 2014 at 9:52 am #122421Genesis Developer
Memberare you using genesis blog page template? or you just wanting this for home page? Can you give your site url?
September 2, 2014 at 9:57 am #122422korg007
MemberThanks,
yes, using the Genesis blog page template (I think). It's not on the home page.here's the link:
http://www.sayingitforward.ca/my-blog/Cheers,
GSeptember 2, 2014 at 9:58 am #122423Genesis Developer
Memberyou can try this code
add_action('template_redirect', 'sp_custom_post_content'); function sp_custom_post_content(){ // only work for home & blog template page if( is_home() || is_front_page() || is_page_template('page_blog.php') ){ remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_post_content', 'genesis_do_post_content' ); add_action( 'genesis_entry_content', 'genesis_do_custom_post_content' ); add_action( 'genesis_post_content', 'genesis_do_custom_post_content' ); } } function genesis_do_custom_post_content(){ global $wp_query; if( $wp_query->current_post == 0 ){ // Only first post will display full content the_content(); }else{ the_content_limit( (int) genesis_get_option( 'content_archive_limit' ), __( '[Read more...]', 'genesis' ) ); } }
You can change the conditional tag
if( is_home() || is_front_page() || is_page_template('page_blog.php') ){
based on your requirement.
September 2, 2014 at 10:03 am #122424Genesis Developer
MemberOk. Then change this line
if( is_home() || is_front_page() || is_page_template('page_blog.php') ){
by
if( is_page_template('page_blog.php') ){
you'll write the full the code in your functions.php file
September 2, 2014 at 10:05 am #122425korg007
MemberThanks for the quick response!
I'm coming from Joomla so bear with me.Do I change or add this code? and... is this all in functions.php of the theme?
I'm assuming there isn't a plugin so I don't have to mess with theme code which will be reset when I update the theme?
If I were to use the READMORE feature (manually in each post) instead of the using the char limit. How do I configure my installation for each post in the blog list to display the first image found in the post, as a "feature image"?
GSeptember 2, 2014 at 11:50 am #122437korg007
MemberI'm confused. Do I simply add the first code snippets in functions.php of the theme?
Thanks,
GSeptember 2, 2014 at 12:15 pm #122442korg007
MemberHi again genwrock,
I added the code at the bottom of the theme's functions.php and changed the cond statement as you suggested.
Nothing changed at all.
What am i missing?September 2, 2014 at 12:54 pm #122450Genesis Developer
MemberI’m coming from Joomla so bear with me.
Are you using Genesis framework? I don't anything about Joomla.
September 2, 2014 at 12:55 pm #122452korg007
MemberYes I am. The lifestylePro theme.
September 2, 2014 at 2:11 pm #122476Genesis Developer
MemberOk. Are you added this full code in your functions.php file?
add_action('template_redirect', 'sp_custom_post_content'); function sp_custom_post_content(){ // only work for home & blog template page if( is_page_template('page_blog.php') ){ remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_post_content', 'genesis_do_post_content' ); add_action( 'genesis_entry_content', 'genesis_do_custom_post_content' ); add_action( 'genesis_post_content', 'genesis_do_custom_post_content' ); } } function genesis_do_custom_post_content(){ global $wp_query; if( $wp_query->current_post == 0 ){ // Only first post will display full content the_content(); }else{ the_content_limit( (int) genesis_get_option( 'content_archive_limit' ), __( '[Read more...]', 'genesis' ) ); } }
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.