Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1253883
    Rad
    Moderator

    Hi there,

    The “read more” is only applicable for excerpt generated by WordPress, and not for excerpt manually added. Example, this text is added to your post’s excerpt in admin.

    This is Alina Tanasa’s watercolor fashion illustration, painted by Madalina Zlamparet. Alina Tanasa is the co-founder of fabulousmuses.net.

    If you wish to add “read more” to manually added text, then please add this code to your child theme’s functions.php

    add_filter('the_excerpt', 'manual_excerpt_read_more', 9999);
    
    function manual_excerpt_read_more ( $excerpt ) {
    
    global $post;
    
    return empty( $post->post_excerpt ) ? $excerpt : sprintf( '<a class="read-more" href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( 'Read More', '__x__ ) );
    
    }

    Hope this helps.

    #1254306
    Andrei
    Participant

    Hi Rad,

    Thank you for your reply.

    I tried to add this code and I get this error:
    Parse error: syntax error, unexpected ”__x__ ) ); ‘ (T_ENCAPSED_AND_WHITESPACE) in /home/forexc9/public_html/sinestezic.com/wp-content/themes/x-child/functions.php on line 259

    #1254317
    Christopher
    Moderator

    Hi there,

    Please update your code to :

    add_filter('the_excerpt', 'manual_excerpt_read_more', 9999);
    
    function manual_excerpt_read_more ( $excerpt ) {
    
    global $post;
    
    return empty( $post->post_excerpt ) ? $excerpt : sprintf( '<a class="read-more" href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( 'Read More', '__x__') );
    
    }

    Hope it helps.

    #1256105
    Andrei
    Participant

    Hi Christopher,

    Now I can’t see the excerpt.

    #1256221
    Paul R
    Moderator

    Hi,

    Please change the code to this.

    
    add_filter('the_excerpt', 'manual_excerpt_read_more', 9999);
    
    function manual_excerpt_read_more ( $excerpt ) {
        global $post;
        if( empty( $post->post_excerpt )) {    
            echo $excerpt;  
        } else {             
            echo sprintf( '<p>%1$s</p><a class="read-more" href="%2$s">%3$s</a>', $post->post_excerpt,get_permalink( get_the_ID() ), __( 'Read More', '__x__') );
        }
    }
    

    Thanks

  • <script> jQuery(function($){ $("#no-reply-1250766 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>