I have a WordPress site with titles, and if the title has more than 50 characters I need to add an ellipsis (...
) at the end of the title and stop the title at 50 characters.
Below is the PHP I am writing but it seems to not work correctly.
<?php if (strlen("the_title()") > 50) { ?>
<?php the_title(); ?>
<?php } if (strlen("the_title()") < 50) { ?>
<?php echo substr(get_the_title(), 0, 50); ?>...
<?php } ?>