Defining Where Excerpt Begins
-
I am trying to shave off a few characters or pieces of text we have in our posts. We have the date and source from which the story in our posts cam but I would not like that included in our excerpt and the formatting people insist that it must remain at the top of the post. How would I go about specifying exactly where I would like the excerpt to begin in the post? Could I have it begin at something like a tag or could I set the number of characters to skip before it begins? Any help would be greatly appreciated. Here is my code thus far:
<phpcode> <?php $my_query = new WP_Query('category_name=science&showposts=5'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <div id="postlist_container"> <h4 class="und"></h4> <?php get_the_image(array( 'image_scan' => true , 'image_class' => 'small_image_left','width' => 80 , 'height' => 80)); ?><div class="post_desc"><date><?php the_time('M j, Y') ?></date> · <a href="<?php the_permalink() ?>"> <?php the_title(); ?></a> <br /><br /><?php the_excerpt_max_charlength(250); ?> </div> </div> <div class="clear"></div> <?php endwhile; ?> <?php 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 '[...]'; } else { echo $excerpt; } } ?> </phpcode>
- The topic ‘Defining Where Excerpt Begins’ is closed to new replies.