Community Forums › Forums › Archived Forums › General Discussion › Remove Blog Listings from Content Archives
Tagged: agency pro, blog, blog listing page, content archives
- This topic has 5 replies, 3 voices, and was last updated 9 years, 10 months ago by Flawed.
-
AuthorPosts
-
November 4, 2014 at 9:45 am #130420FlawedMember
Hello 🙂
I currently have the following settings for the Content Archives:
Display Post Content
0 Characters
NO - Display Featured ImageThis suits perfectly, except for the blog listing page in which I would like the following settings:
Display Post Excerpt
200 Characters
YES - Display Featured ImageI did follow the instructions here http://www.shilling.id.au/2012/10/22/genesis-framework-how-to-show-experts-or-full-content-on-archive-pages/ although it didn't work for the character limit nor the featured image.
Any help would be much appreciated.
Many Thanks
http://katiekingdesign.com/
NicolaNovember 15, 2014 at 5:07 pm #131683neilgeeMemberYou can try the code below, adjust your character count where it is commented
add_action('genesis_before_loop', 'wpb_change_home_loop'); function wpb_change_home_loop() { if( is_home() ) { /** Replace the home loop with our custom **/ remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'wpb_custom_loop' ); /** Custom lode loop */ function wpb_custom_loop() { if ( have_posts() ) : do_action( 'genesis_before_while' ); while ( have_posts() ) : the_post(); do_action( 'genesis_before_entry' ); printf( '<article %s>', genesis_attr( 'entry' ) ); do_action( 'genesis_entry_header' ); do_action( 'genesis_before_entry_content' ); printf( '<div %s>', genesis_attr( 'entry-content' ) ); //do_action( 'genesis_entry_content' ); //Remove standard excerpt echo genesis_do_post_image(); //Add in featured image echo the_excerpt_max_charlength(200); //change amount of characters to display echo '</div>'; do_action( 'genesis_after_entry_content' ); do_action( 'genesis_entry_footer' ); echo '</article>'; do_action( 'genesis_after_entry' ); endwhile; //* end of one post do_action( 'genesis_after_endwhile' ); else : //* if no posts exist do_action( 'genesis_loop_else' ); endif; //* end loop } } } //Limit the excerpt by character - http://codex.wordpress.org/Function_Reference/get_the_excerpt function the_excerpt_max_charlength($charlength) { $excerpt = get_the_excerpt(); $charlength++; if ( mb_strlen( $excerpt ) > $charlength ) { $subex = mb_substr( $excerpt, 0, $charlength - 5 ); $exwords = explode( ' ', $subex ); $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); if ( $excut < 0 ) { echo mb_substr( $subex, 0, $excut ); } else { echo $subex; } echo ' <br><a href="' . get_permalink() . '" class="more-link" title="Read More">Read More</a>'; } else { echo $excerpt; } }
https://gist.github.com/neilgee/144c3c9203c958daadbe
Neil Gee
WP Beaches
Coolest GuidesNovember 15, 2014 at 7:01 pm #131696MealtogMemberInteresting @neilgee. Can this code be used to overide WP + Genesis default Archive Page? Reason being, SP code does not work with non-Latin languages. Running a client with Chinese text and Character count for Content does not work. (yes, took this up with SP staff and they do not have a fix).
November 15, 2014 at 11:05 pm #131706neilgeeMemberYes you can target default archive page as well just change the condition
if( is_home() || is_archive() )
For translations you need - Remkus de Vries plugin/
Neil Gee
WP Beaches
Coolest GuidesDecember 4, 2014 at 10:20 am #133593December 4, 2014 at 10:23 am #133594FlawedMemberJust one question though....how do I get the featured image to show?
Many thanks 🙂
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.