WordPress.org

Ready to get started?Download WordPress

Forums

Limit Character Count in the_content; keep MORE link (2 posts)

  1. sergibosch
    Member
    Posted 3 years ago #

    i found this post in the forum that explained how to reduct the character count.

    however, the "More" attribute disappears. How can i include the "More" link while incorporating this function?

    thanks!

    function content($num) {
    $theContent = get_the_content();
    $output = preg_replace('/<img[^>]+./','', $theContent);
    $output = preg_replace( '/<blockquote>.*<\/blockquote>/', '', $output );
    $output = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $output );
    $limit = $num+1;
    $content = explode(' ', $output, $limit);
    array_pop($content);
    $content = implode(" ",$content)."...";
    echo $content;
    }
  2. borantula
    Member
    Posted 3 years ago #

    you can add it manually as html to the $content variable at the end of the function as if its excerpt

Topic Closed

This topic has been closed to new replies.

About this Topic