Can I limit number of characters within titles?


Here’s a sample of a template to get you started, based on the “Simple” example template provided by YARPP:

YARPP Template: Short Titles
Author: YARPP Team
Description: A simple example YARPP template.
function yarpp_trim_title($title){
	$max = 50;
	if(strlen($title) > $max) {
		$title = substr( $title, 0, $max ) . '&hellip;';
	return $title;
?><h3>Related Posts</h3>
<?php if (have_posts()):?>
		<?php while (have_posts()) : the_post(); ?>
			<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo yarpp_trim_title(get_the_title()); ?></a><!-- (<?php the_score(); ?>)--></li>
		<?php endwhile; ?>
<?php else: ?>
	<p>No related posts.</p>
<?php endif; ?>

To use it, create a file in your theme’s root folder called ‘yarpp-template-short-titles.php`, and paste that into it. Then you should see a new custom YARPP template called “Short Titles”.