[Resolved] 'Read More' button not showing on blog page with custom excerpts

Home Forums Support 'Read More' button not showing on blog page with custom excerpts

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1235767
    Megan

    Hi there, I have set custom excerpts for blog posts, however now on the blog page (which is set to display recent posts), the read more button has disappeared.

    Having looked through the support forum, and your documentation pages, I have tried to fix this by adding the following to simple CSS, but it does not work:

    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”>%3$s</p>’,
    $excerpt,
    get_permalink(),
    __( ‘Read more’, ‘generatepress’ )
    );
    }

    return $output;
    }

    Being that the above does not work, do you have coding which I can add to simple CSS which will reinstate the read more buttons when custom excerpts are enabled?

    Thanks 🙂

    #1235897
    Suraj Katwal

    Hi, it’s not the CSS code.
    Instead follow the process like this.
    Go to Plugins > Add New
    Search Code Snippets Plugin. Install the plugin and Activate
    And then Go to Snippets and Click on Add New
    Give the name to the New Snippets and Paste the following code and Hit Activate

    View post on imgur.com

    add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
    function tu_excerpt_metabox_more( $excerpt ) {
    	$output = $excerpt;
            $settings = wp_parse_args( 
    		get_option( 'generate_blog_settings', array() ), 
    		generate_blog_get_defaults() 
    	);
    	
    	if ( has_excerpt() ) {
    		$output = sprintf('%1$s <br /><a class="read-more" href="%2$s">%3$s  →</a>',
    			$excerpt,
    			get_permalink(),
                            wp_kses_post( $settings['read_more'] )
    		);
    	}
    	
    	return $output;
    }

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

    #1235900
    Megan

    Thanks for the help, that works now 🙂

    Happy Easter!

    #1235988
    Suraj Katwal

    Welcome and Happy Easter 🙂

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

    #1236346
    David
    Staff
    Customer Support
    #1236479
    Suraj Katwal

    Welcome 🙂

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

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