[Resolved] Double buttons from Read More

Home Forums Support [Resolved] Double buttons from Read More

Home Forums Support Double buttons from Read More

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #931720
    Todd

    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

    #931725
    Leo
    Staff
    Customer Support

    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 🙂

    #932085
    Todd

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

    #932423
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.