[Resolved] Filter/code for making the 'Read More' button no-follow

Home Forums Support [Resolved] Filter/code for making the 'Read More' button no-follow

Home Forums Support Filter/code for making the 'Read More' button no-follow

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1241719
    Yoeri

    Hey GP!

    I’m looking for a PHP code/filter so my Read More buttons are no-follow. Can you help me with that?

    Much thanks and have a great day! πŸ™‚

    #1241957
    Leo
    Staff
    Customer Support

    Hi there,

    Give this snippet a shot:

    add_filter( 'generate_excerpt_more_output', 'tu_blog_read_more_button' );
    add_filter( 'generate_content_more_link_output', 'tu_blog_read_more_button' );
    function tu_blog_read_more_button( $output ) {
    	$settings = wp_parse_args(
    		get_option( 'generate_blog_settings', array() ),
    		generate_blog_get_defaults()
    	);
    
    	if ( ! $settings[ 'read_more_button' ] ) {
    		return $output;
    	}
    
    	return sprintf( '%5$s<p class="read-more-container"><a title="%1$s" class="read-more button" href="%2$s" rel="nofollow"	
    >%3$s%4$s</a></p>',
    		the_title_attribute( 'echo=0' ),
    		esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump','#more-' . get_the_ID() ) ),
    		wp_kses_post( $settings['read_more'] ),
    		'<span class="screen-reader-text">' . get_the_title() . '</span>',
    		'generate_excerpt_more_output' == current_filter() ? ' ... ' : ''
    	);
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1242538
    Yoeri

    Hi Leo,

    That works perfectly! Thank you very much πŸ˜€

    #1243192
    Leo
    Staff
    Customer Support

    No problem πŸ™‚

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