Substr () doesn't work to crop the_content () in wordpress widgets

<div class="wpex-recent-posts-content clr"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><p> <?php $content = the_content(); echo substr($content,0,100); ?> </p> </div> 

here echo substr($content,0,100); doesn't work to trim content from 0 to 100. This is in my_theme/functions/widgets/widget-portfolio-posts-thumbs.php

+8
php wordpress
source share
2 answers

Try the following:

 $content = get_the_content(); $content = strip_tags($content); echo substr($content, 0, 100); 
+16
source share

This is because the_content () really outputs the content. What you want to use is get_the_content () .

+4
source share

All Articles