[Resolved] Read More button after excerpt

Home Forums Support [Resolved] Read More button after excerpt

Home Forums Support Read More button after excerpt

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #652894
    Stella

    Hi All,

    I have followed the link below to add the PHP to bring the read more button back.

    https://docs.generatepress.com/article/activating-read-custom-excerpt/

    And the read more button successfully returned.

    However, I have changed the size of the buttons using CSS below, but read more buttons from those posts with the custom excerpt are not applied.

    .read-more-container {
    text-align: center;
    }
    .read-more-container a {
    display: block;
    }
    .button {
    border-radius: 1px;
    padding: 13px
    }

    Could you please help? Thank you!

    GP Premium 1.7.1
    #653120
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can edit the original topic and use the private URL field.

    Let me know πŸ™‚

    #653236
    Stella

    Hi Leo,

    I have added the website link. Thank you!!

    #653625
    Leo
    Staff
    Customer Support

    I’m not quite sure what you mean?

    The page you linked is using WP Show Posts and the CSS above applied?

    #653704
    Stella

    The link is the home page with GP only – PHP and CSS above applied.

    And it has two posts: Test Post and Test Post 2

    The Test Post has the read more button fully customised with the CSS above applied.

    On the other hand, the Test Post 2 has the manual excerpt and the read more button disappeared.
    I used the PHP from the link above to bring the read more button back.
    However, the CSS is not applied on the read more button anymore on this particular posts with the manual excerpt.

    My question is how to customise the read more button even with the manual excerpt?

    #653852
    Leo
    Staff
    Customer Support

    Can you try this for your PHP snippet?

    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-container"><a class="button" href="%2$s">Read more</a></p>',
    			$excerpt,
    			get_permalink()
    		);
    	}	
    	return $output;
    }

    Let me know πŸ™‚

    #654904
    Stella

    Perfect! It worked. Thank you very much Leo!

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