lundi 1 août 2016

if statement to compare Character Length of the_content();

I need to compare the Character Length of my Custom Post Type post->content I have displayed the content by limiting to 200 words.

<?php $content = get_the_content(); 
echo substr($content, 0, 200); ?>

However, I need to trigger something if character exceeds 200 words.

Similar to like this:

if( character_length > 200 ) , Popup link to display the whole content.

I searched on StackOverflow and Google but couldn't find the right solution.

Any help would be appreciated

Aucun commentaire:

Enregistrer un commentaire