I am costuming a template. There is a list grabbing the introduction from the first 1-2 paragraphs (all the articles from a category). If I set the excerpt to 295 words, sometimes the list grabs additional words from the next paragraph. I would like to add a Read More tag to stop it. Can someone help me with that part?
<div id="all-div-cabrand-content-stories">
<div class="kids-families-con-cabrand-stories">
<?php echo get_the_post_thumbnail($page->ID, 'thubmnailstorysmall'); ?>
</div>
<div class="kids-con-cabrand-new-stories">
<span>
<?php print substr(get_the_excerpt(),wp_trim_excerpt(),295); ?>
<i><a style="color:#1975D1;float:Right;" class="title" href="https://wordpress.stackexchange.com/questions/75069/<?php the_permalink() ?>" rel="bookmark">Click for Story & Video</a></i>
<br/>
</span>
</div>
</div>
5 s
To get a specific length you can use: wp_trim_words function. It has 3 parameters.
- Text to trim. Ex:
get_the_content()
- Number of words. Ex:
295
- What to append after end of the text. Ex:
''
This means null.
Use this:
<span>
<?php echo wp_trim_words( get_the_content(), 295, '' ); ?>
<i><a style="color:#1975D1;float:Right;" class="title" href="https://wordpress.stackexchange.com/questions/75069/<?php
the_permalink() ?>" rel="bookmark">Click for Story & Video</a></i>
<br/>
</span>