Support » Themes and Templates » More on excerpt only on longer excerpts

  • Hello,

    I use the script below. But it always puts the more link after the excerpt. I want to modify it a little bit so that it only shows the more link after a certain length.

    So how can I ask the lenght of the post in characters?

    So I can add that as a variable and than later ask, if $lenght > postCharacters than add the more tag

    function dynamic_excerpt($length) { // Variable excerpt length. Length is set in characters
    	global $post;
    	$permalink = get_permalink($post->ID);
    	$text = $post->post_excerpt;
    	if ( '' == $text ) {
    	$text = get_the_content('');
    	$text = apply_filters('the_content', $text);
    	$text = str_replace(']]>', ']]>', $text);
    	$text = mb_substr($text,0,$length). ' <a href="'.$permalink.'">more ...</a>';
    	echo apply_filters('the_excerpt',$text);
  • The topic ‘More on excerpt only on longer excerpts’ is closed to new replies.