WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] target="_blank" for a page on menu? (56 posts)

  1. Stepping waaaaay back on this... Are you using WordPress' menu system (Under Apperance -> Menu)?

    Because you can do that fairly easily by clicking on 'Screen Options' (upper right hand corner) and checking the box for 'Link Target'

    Then when you edit your menu items, it'll show a checkbox for "Open link in a new window/tab"

  2. Bhavadasa
    Member
    Posted 2 years ago #

    I really appreciate all your help! Here's the code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
    <head profile="http://gmpg.org/xfn/11">
    <title>
    <?php if (is_home()) { ?>
    <?php bloginfo('name'); ?>
    -
    <?php bloginfo('description'); ?>
    <?php } else { ?>
    <?php wp_title($sep = ''); ?>
    -
    <?php bloginfo('name'); ?>
    <?php } ?>
    </title>
    <meta http-equiv="content-type" content="<?php bloginfo('html_type') ?>; charset=<?php bloginfo('charset') ?>" />
    <meta name="description" content="<?php bloginfo('description') ?>" />
    <?php if(is_search()) { ?>
    <meta name="robots" content="noindex, nofollow" />
    <?php }?>
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/coin-slider-styles.css" type="text/css" />
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/menusm.css" type="text/css" />
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/cufon-yui.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/PT_Sans.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/custom.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/menusm.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/coin-slider.min.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/hoverintent.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/superfish.js"></script>
    <!-- Start Of Script Generated By WP-PageNavi 2.40 -->
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/pagenavi-css.css" type="text/css" media="screen" />
    <!-- End Of Script Generated By WP-PageNavi 2.40 -->
    <?php wp_head(); ?>
    </head>
    <body>
    <?php if (is_front_page()) { ?>
    <div id="page2">
    <?php } else { ?>
    <div id="page">
    <?php } ?>
    <div id="header">
      <div class="logo_resize">
        <div class="logo">
          <h1><a href="<?php echo get_option('home'); ?>" title="<?php bloginfo('name'); ?> - <?php bloginfo('description'); ?>">
            <?php bloginfo('name'); ?>
            </a></h1>
          <small class="slogan">
          <?php bloginfo('description'); ?>
          </small></div>
        <!-- /logo-->
        <div class="topnav">
          <ul class="menusm">
            <?php wp_list_pages('title_li='); ?>
          </ul>
        </div>
        <!--/topnav -->
      </div>
      <div class="clr"></div>
      <?php if (is_front_page()) { ?>
      <div class="slider">
        <div id="coin-slider">
          <div id="nav_wrapper"><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/simple_img_1.jpg" width="960" height="470" alt="slide1" /></a><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/simple_img_2.jpg" width="960" height="470" alt="slide2" /></a> <a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/simple_img_3.jpg" width="960" height="470" alt="slide3" /></a> <a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/simple_img_4.jpg" width="960" height="470" alt="slide4" /></a> </div>
        </div>
        <div class="clr"></div>
      </div>
      <div class="clr"></div>
      <!--/slider -->
      <?php } ?>
    </div>
    <!--/header-->
  3. Bhavadasa
    Member
    Posted 2 years ago #

    Unfortunately, (I think) the menu will show up in a sidebar instead.

    Here's that page's statement:

    "The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar."

  4. Bhavadasa
    Member
    Posted 2 years ago #

    OK, the slider issue has been fixed. The cause appeared to be a conflict from a newly installed plugin. I delete it, and now issue is done with.

    However........now when I click on the Discussions link, the new tab that opens along with the original tab, both go to the Discussions board.

    Please don`t give up on me anevins.

  5. Andrew
    Forum Moderator
    Posted 2 years ago #

    That's really odd..

  6. Andrew
    Forum Moderator
    Posted 2 years ago #

    First I'd remove the duplicate

    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>

    You only need one instance of this code, I suppose this is a mistake.

  7. Bhavadasa
    Member
    Posted 2 years ago #

    Thanks for replying anevins. Have any ideas, besides just scrapping it.

  8. Andrew
    Forum Moderator
    Posted 2 years ago #

    Have you removed the duplicate?

  9. Bhavadasa
    Member
    Posted 2 years ago #

    Sorry for the delay. Had to reboot.

    What I did was to replace the previous code with this last one.

    In the previous code there was a "." between item & page (item.page).
    Now, with the "." removed, it opens discussions in the same tab, not another one.

  10. Andrew
    Forum Moderator
    Posted 2 years ago #

    Sorry, I see what you mean.
    Just remove this

    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>

    Keep the one with the dot

  11. Bhavadasa
    Member
    Posted 2 years ago #

    Ok, I did that, and the same thing as before happened--a new tab opens, displaying Discussions, and the original tab also now displays Discussions. So both are displaying Discussions.

  12. Bhavadasa
    Member
    Posted 2 years ago #

    This is why I never ended up doing programing--I just don't have the patients!

  13. Andrew
    Forum Moderator
    Posted 2 years ago #

    I think it's to do with a plugin for your navigation menu, because when I add target="_blank" to your 'GET IN TOUCH' button, it opens a new tab but doesn't change the current page.

  14. Bhavadasa
    Member
    Posted 2 years ago #

    I just deactivated everything, but the same thing continues.

  15. Andrew
    Forum Moderator
    Posted 2 years ago #

    It only occurs within the
    <li> of the menu

    If (just to test) you change the
    <li> to a <p>, this problem is solved, so it is definately to do with some funny-business going on with the <li>

  16. Bhavadasa
    Member
    Posted 2 years ago #

    Can I do anything about it?

  17. Andrew
    Forum Moderator
    Posted 2 years ago #

    I still see this

    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>

    Are you sure you removed it?

  18. Bhavadasa
    Member
    Posted 2 years ago #

    Sorry, I misunderstood that. I should change
    <li> to <p>?

  19. Bhavadasa
    Member
    Posted 2 years ago #

    I think I'm taking too much of your time! I'll just have to live with it on another part of the page. I have other questions to ask, and don't want to fry you out.

    Thanks for sticking in there with me!

  20. Andrew
    Forum Moderator
    Posted 2 years ago #

    It's alright, I'm asking you to remove this code

    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>

    (but keep the code with the dot)

    I was talking about the <p> hypothetically.

  21. Bhavadasa
    Member
    Posted 2 years ago #

    Well, I did do that, but the source and the target pages both load as discussions.

  22. Andrew
    Forum Moderator
    Posted 2 years ago #

    I suspect this is still due to both jQuery codes in the page:

    You don't want this (below)

    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>

    You want this (below)

    <script type="text/javascript">
    $('li.page_item.page-item-136 a').attr('target','_blank')
    </script>
  23. Bhavadasa
    Member
    Posted 2 years ago #

    You were right. There was another one...way up at the top. I've removed it.

    I did notice this right before this script:

    <?php wp_footer(); ?>

    I don't know enough about script. Is this supposed to be closed at the end? </> or something?

  24. Andrew
    Forum Moderator
    Posted 2 years ago #

    The last thing I'll recommend is changing

    <script type="text/javascript">
    $('li.page_item.page-item-136 a').attr('target','_blank')
    </script>

    to

    <script type="text/javascript">
    $('li.page-item-136 a').attr('target','_blank')
    </script>
  25. Bhavadasa
    Member
    Posted 2 years ago #

    Well, I must have done something, somewhere I shouldn't have.

    Anyway, I tried that with the same result. I would have liked that link on the menu, but I'll just have to find somewhere else for it.

    I really appreciate your time and patients! First class!!!

    Thank you very much!

    Yikes! 9 hours!

  26. JacobKing
    Member
    Posted 1 year ago #

    Or you can install WP links the external link handler automatically parses target_blank on all external links.

    http://wordpress.org/extend/plugins/wp-links/

Topic Closed

This topic has been closed to new replies.

About this Topic