WordPress.org

Ready to get started?Download WordPress

Forums

Redirect by Custom Field
[resolved] Open redirection to new tab? taget _blank? (9 posts)

  1. 3x7
    Member
    Posted 2 years ago #

    Anyway to add option to open the redirected link in a new window or tab?

    Tnx

    http://wordpress.org/extend/plugins/redirect-by-custom-field/

  2. Thiago Miro
    Member
    Posted 1 year ago #

    How did you fix it? My redirections are not opening on new window.

  3. 3x7
    Member
    Posted 1 year ago #

    Edit your theme file and where permalink is put this in:

    <a href="<?php echo($permalink); ?>" title="<?php the_title_attribute(); ?>" rel="nofollow" target="_blank">SOME TEXT</a>

  4. Thiago Miro
    Member
    Posted 1 year ago #

    Is there a way to make "target='_blank'" only for the redirected links?

  5. 3x7
    Member
    Posted 1 year ago #

    put it in
    "if the custom field $redirect" is not empty then open in new tab,
    else just open "permalink"

  6. hughes1974
    Member
    Posted 1 year ago #

    did you get this to work? and how?

  7. Thiago Miro
    Member
    Posted 1 year ago #

    No. I'd like that only the redirected links to open in a new tab.

  8. 3x7
    Member
    Posted 1 year ago #

    Did you try with plugins for opening external link in a new window/tab?

    open-external-links-in-a-new-window
    or
    wp-external-links

    If this don't work for you, here is the code that will replace the "redirect by custom field" (u should disable it if u use this).

    It will check if there is a redirect custom field and if there is, it will change normal permalink to the link in the redirect meta.

    $meta = get_post_custom();
    if($meta['redirect'][0]) {
     $permalink = $meta['redirect'][0];
    } else {
     $permalink = get_permalink();
    }

    This way I think the plugin for external links should recognize it is external.

    Cheers!

  9. Thiago Miro
    Member
    Posted 1 year ago #

    Finally I found a way:

    <?php if ( function_exists('redirect') ){echo'target="_blank"';} ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.