Site logo

Archived topic

Double buttons from Read More

3 replies · Started by Todd on June 16, 2019

Viewing posts 1–4 of 4

Hello, below is a testing version of the home page. In the “why surgical one” area of the page I am adding a “read more” button with the WP show post plugin. However, I just set up a news area on the site and have added a read more with the following snippet from your documentation.

I now get 2 buttons as you see on this testing page home page. I put a display none CSS to hide one set of the buttons on the actual home page. Is there a better or more elegant and global way to handle this going forward?

Snippet from the document below to add a read more on News (blog): https://docs.generatepress.com/article/activating-read-custom-excerpt/#read-more-button

News (blog) section:
https://surgicalone.com/news/

Testing Home page:
Preview in the admin area

Hi there,

Can you try this code instead?

add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
    $output = $excerpt;

    if ( has_excerpt() && is_home() ) {
        $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;
}

Let me know :)

Leo, worked perfectly. Thank you for such a quick reply.

No problem :)

This archived topic is closed to new replies.