0

(Using wordpress)I tried to find out what's the php code to display the length text of content and likely a clickable 'more' under the content to display my full content when somebody click (like in this picture - enter image description here ) but unfortunately I couldn't do it, this is the code I tried out so far:

$character == 40;

if (mb_strlen( get_the_content() < $character)

( have_posts() ) ( have_posts() ) : the_post();

the_content();

else{

the_content('Continue Reading...')

}

I highly think my code is not right, so if theres somebody out there to take a eye on and tell me if my code is incorrect or there's a other way to do this this I'd appreciate it alot :). Thanks in return!

0

Inside your loop use this:

<p><?php $excerpt = get_the_content(); if (strlen($excerpt) > 255) { $excerpt = substr($excerpt, 0, 255) . "..."; echo $excerpt; } ?></p>

Here get_the_content() will grab all the content but substr function will cut it down to 255, you can put any number you want.

Cheers !!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.