Question Detail

How to use substring() function with the_content() in worpress?

6 years ago Views 1710 Visit Post Reply

 

How to use substring() function with the_content() in worpress?

I am using this code;

<?php echo substr(the_content(), 0, 5) ?>

but code is not working.


Thread Reply

Manish Kumar

- 6 years ago

You can use this code:

<?php

       $content = get_the_content();
       $content = strip_tags($content);
       echo substr($content, 0, 20);

   ?>