Site logo

[Resolved] Continue Reading button not showing on Archives

Home Forums Support [Resolved] Continue Reading button not showing on Archives

Home Forums Support Continue Reading button not showing on Archives

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2451671
    Glen

    Example Archives Page: https://www.glenhuff.com/category/social-media-best-practices/page/4/

    For some reason, none of the blog posts on an archive page have a “Continue Reading” link after the excerpt. I have the label set in the settings under:
    Theme > Customize > Blog > Archives > Read more label = “Continue Reading”. Yet, nothing appears. The title links to the single blog posts, but I wanted a read more button after the excerpt. How do I do this?

    #2451911
    Leo
    Staff
    Customer Support
    #2451940
    Glen

    Thank you. I found a link on that page useful. It sent me to this: https://docs.generatepress.com/article/activating-read-custom-excerpt/

    I added the following code to the theme-functons.php file and it worked.

    add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
    function tu_excerpt_metabox_more( $excerpt ) {
        $output = $excerpt;
    
        if ( has_excerpt() ) {
            $output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
                $excerpt,
                get_permalink(),
                __( 'Read more', 'generatepress' )
            );
        }
    	
        return $output;
    }

    Is this something I’ll have to add every time the theme updates?

    #2451951
    Leo
    Staff
    Customer Support

    I added the following code to the theme-functons.php file and it worked.

    Please do not edit the parent theme’s function.php file.

    Use one of these methods instead: https://docs.generatepress.com/article/adding-php/

    #2451973
    Glen

    Using a child theme seems like the easiest route. I don’t have one installed. Is there a download for the GP child theme?

    #2451992
    Leo
    Staff
    Customer Support

    The Code Snippets plugin suggested is actually the easiest route and the option I would pick if you aren’t using a child theme already.

    If you prefer to use a child theme: https://docs.generatepress.com/article/using-child-theme/

    #2452024
    Glen

    Okay, I have the child theme installed. My function to show continue reading buttons with excerpts has been added. The archives look great.

    But, now I’m seeing a continue reading button on the single post. The theme I’m using displays the excerpt as the first paragraph in a Hero Full-Width fashion.

    Example: https://www.glenhuff.com/how-to-create-a-winning-social-media-strategy/

    #2452043
    Leo
    Staff
    Customer Support

    Can you edit the function to this instead?

    add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
    function tu_excerpt_metabox_more( $excerpt ) {
        $output = $excerpt;
    
        if ( has_excerpt() && !is_single() ) {
            $output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
                $excerpt,
                get_permalink(),
                __( 'Read more', 'generatepress' )
            );
        }
    	
        return $output;
    }
    #2452067
    Glen

    Works perfectly! Thank you.

    #2452069
    Leo
    Staff
    Customer Support

    Glad to help 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.