[Resolved] Read More link open in new tab

Home Forums Support [Resolved] Read More link open in new tab

Home Forums Support Read More link open in new tab

  • This topic has 3 replies, 2 voices, and was last updated 1 year ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1492783
    Joyce

    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

    #1492884
    David
    Staff
    Customer Support

    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/

    #1492917
    Joyce

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

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