Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

substr() not working to trim the_content() in wordpress widget

Tags:

php

wordpress

<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); is not working to crop content from 0 to 100. This is located in my_theme/functions/widgets/widget-portfolio-posts-thumbs.php

like image 455
LIGHT Avatar asked Mar 19 '14 12:03

LIGHT


1 Answers

Try this one:

$content = get_the_content();
$content = strip_tags($content);
echo substr($content, 0, 100);
like image 126
Danny Avatar answered Nov 15 '22 15:11

Danny