WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Adding "Read More" Links to posts (5 posts)

  1. wifsster
    Member
    Posted 4 months ago #

    I would like to add either a "read more" or "continue reading" to some of my posts. I have seen plugins that do this, but I can't seem to get them to work. I was wondering if there is something with the Customizr Template that prevents this from working.

    I would love to hear a solution or an idea if anyone has one.

    Thank you.

  2. tomaja
    Member
    Posted 4 months ago #

    Hi @wifsster
    add this function

    function new_excerpt_more($more) {
       global $post;
       return ' <a href=" ' .get_permalink($post->ID). '" class="read-more">' . 'Read more >' . '</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    to functions.php file in your Customizr child theme folder.

  3. wifsster
    Member
    Posted 4 months ago #

    Thank you @tomaja, it's working intermittently, Could be because some of my blog articles are very short, however the first article in my blog is quite long and the "read more" link is not showing there. I've added the link to the blog below for you to take a look. Your assistance is greatly appreciated.

    http://www.wifss.ucdavis.edu/?page_id=17

  4. bravokeyl
    Member
    Posted 4 months ago #

    If you are using manual excerpts you need to add the following code(i mean if you are using excerpt meta box),

    function childtheme_excerpt_read_more_link($output) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '"> Read More...</a>';
    }
    add_filter('the_excerpt', 'childtheme_excerpt_read_more_link');

    If you are using both types(Generated and manual) you need to add like this whole code in functions.php of child theme:

    <?php
    function childtheme_excerpt_more($more) {
       global $post;
       return ' ';
    }
    add_filter('excerpt_more', 'childtheme_excerpt_more');
    
    function childtheme_excerpt_read_more_link($output) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '"> Read More...</a>';
    }
    add_filter('the_excerpt', 'childtheme_excerpt_read_more_link');
    
    ?>
  5. wifsster
    Member
    Posted 4 months ago #

    Thanks to you both @tomaja and @bravokeyl , it's working great, You are greatly appreciated.

    -@wifsster

Reply

You must log in to post.

About this Theme

About this Topic