WordPress.org

Ready to get started?Download WordPress

Forums

How to get 'continue reading' read more to open in new window? (4 posts)

  1. AjayTCT
    Member
    Posted 4 years ago #

    I know that target="_blank" open a link in a new window. My question is where do I place it in order to have the link open in a new window when the 'continue reading' link is clicked after the post excerpt on the blog homepage?

    Help please?

  2. MichaelH
    Member
    Posted 4 years ago #

    Might get some ideas in Customizing_the_Read_More.

  3. ryans149
    Member
    Posted 4 years ago #

    It will be something like this:

    <a href="<?php the_permalink() ?>">Continue ...</a>

    turn it to:

    <a target="_blank" href="<?php the_permalink() ?>">Continue ...</a>

  4. MichaelH
    Member
    Posted 4 years ago #

    Try a filter (tested this with WordPress Default theme by adding to functions.php in wp-content/themes/default/functions.php):

    //make more link open in new window
    function add_blank_to_link($link) {
    $pos = strpos($link, 'a href');
    if ($pos) {
    $link = substr_replace($link, 'a target="_blank" href', $pos, 6);
    }
    return $link;
    }
    add_filter('the_content_more_link', 'add_blank_to_link');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags