Lengthened excerpts 'more quicktag' = too much excerpt
-
Hello all,
I want to ensure that when WP shows an excerpt created with the ‘more’ quicktag, that it does not auto-truncate before or after my placed ‘more’ quicktag. I’m using the Twenty Eleven theme modded to show on homepage x posts full text, then excerpts for additional to my set limit. (See at bottom.)
With this mod, I’m finding that WP will either:
-display by default a short posts as the whole post (no ellipsis or ‘continue reading’ link) which is perfect;
-Show my whole post for those x number that are supposed to be shown full-text on the homepage (also good); or
-auto truncate posts even where I have set a ‘more’ quicktag if they go over the word limit.The old cutoff was 40 words; I’ve extended it to 100 because I’ll set my quicktags to kick in earlier. But as currently displayed, the summary posts on the homepage don’t seem to respect the ‘more’ quicktag.
The site is https://betterbike.org
In my child functions.php I placed this code to lengthen the auto truncate block:
<?php // added to lengthen excerpt add_action( 'after_setup_theme', 'my_child_theme_setup' ); function my_child_theme_setup() { // We are providing our own filter for excerpt_length (or using the unfiltered value) remove_filter( 'excerpt_length', 'twentyten_excerpt_length' ); function new_excerpt_length($length) { return 100; } add_filter('excerpt_length', 'new_excerpt_length'); } ?>
The code I’m using in child’s content.php to show x posts and excerpts for others is FWIW:
<?php global $more; if( $wp_query->current_post <= 2 && !is_paged() ) { $more = -1; } else { $more = 1; } ?> <?php if ( is_search() || $wp_query->current_post > 2 || is_paged() ) : // Only display Excerpts for Search ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div class="entry-content"> <?php the_content( __( 'Continue reading [' . get_the_title($post->ID) . '] <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?> <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?> </div><!-- .entry-content -->
Thanks for any help you can be! I thought the default behavior would be to NOT show text beyond the ‘more’ quicktag, and maybe it is but I might have changed that with the x-full y-excerpts above.
- The topic ‘Lengthened excerpts 'more quicktag' = too much excerpt’ is closed to new replies.