Site logo

Archived topic

Read More link open in new tab

3 replies · Started by Joyce on October 16, 2020

Viewing posts 1–4 of 4

Hi Team,

How can I open 'read more' link in new tab, I modified the following files but after plugin upgrade, I have to re-apply the same change. Is there a better way to handle this?

All links on my website need to open in new tab.

/plugins/gp-premium/blog/functions/generate-blog.php 
<a title="%1$s" class="read-more" href="%2$s" aria-label="%4$s" target="_blank">%3$s</a>

Thanks,
Joyce

Hi there,

add this PHP Snippet to your site:

add_filter( 'generate_excerpt_more_output','lh_change_read_more' );
function lh_change_read_more() {
    return sprintf( ' ... <a class="read-more" title="%1$s" href="%2$s" target="_blank">%3$s</a>',
    the_title_attribute( 'echo=0' ),
    esc_url( get_permalink( get_the_ID() ) ),
    __( 'Read more', 'generatepress' )
  );
}

This article explains adding PHP:

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

Thanks David, I added it to child theme functions.php and it works fine

Glad to hear that

This archived topic is closed to new replies.