I am while using Loop during my own web page to obtain the last three posts from Wordpress.
<?php $args = array( 'numberposts' => 3 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <!-- DATE --> <div class="date"> <?php the_time('m F Y');?> </div> <!-- TITLE --> <div class="title"> <?php the_title(); ?> </div> <!-- SNIPPET --> <div class="content"> <?php the_excerpt(); ?> </div> <?php endforeach; ?>
Things are working fine - except
the_excerpt(). I want about 15-20 words of plain text in the publish to exhibit like a preview. How do you start carrying this out?
You could attempt using something similar to this to seize the very first 20 words from the publish if there's no excerpt available.
$content = get_the_content(); echo substr($content, 0, 20);
To personalize how big the excerpt give a customer excerpt filter, see here
The sub str without a doubt works...it use img also...like if u possess a image and also you would like your text to become limited the sub_str works!