• I am using Custom Menus to create an item (url) that points to an exterkal link, and I would like it to open in a new window. Is that possible?

Viewing 15 replies - 1 through 15 (of 18 total)
  • At the top of the Custom Menus dashboard page click Screen Options.

    Put a check in Link Target and CSS classes (not needed for what you want but good to have visible anyway). Now a Link Target field is added to every menu item that you can set to open in a new window.

    Thread Starter djhomick

    (@djhomick)

    Thanks, that sounds perfect. However, I did what you said and the drop down appeared for my menu option, I set it to open in new window, saved the menu, but it did not work. Tried it in IE & FF. A view of source code shows no target in the A tag. Am I missing something? Have you actually seen this work?

    WP 3.1 and everything up to date.

    hi

    Yes, I have done this in 3.0.5 and it worked. I just sent it up on a test site in 3.1 and it also worked, both for a WordPress page on the site and for an external link. I see target=”_blank” in View Source. This is working in IE FF Chrome.

    Are you positive the theme is using the custom menu and is not falling back to wp_list_pages or wp_page_menu? When using View Source the classes on each menu LI should be like: menu-item menu-item-type-post_type menu-item-object-page menu-item-123 – starting with “menu-item”. If not, its not using the custom menu. I’d start by confirming that is working.

    Thread Starter djhomick

    (@djhomick)

    D’oh! I was changing it on a sub-menu and testing it from the main menu. Sorry about that, but Thanks LOADS for the solution. It is just what I needed.

    I am having this same issue. Mine is a sub menu item on the drop down. I added Link Target and CSS classes as suggested. When I edit the item it now has a place to chose “new window or tab” or “same window and tab”. I chose the new. Saved the menu. refreshed the page. no luck and it’s not in the source. What could be the problem?

    For starters refresh the page in your browser a few times <CTRL> + R to make sure you are seeing the latest version and not a browser cached version.

    If that’s not it double check everything you did because what you said you did is what you are supposed to do.

    If you still can’t find it, as I said originally

    Are you positive the theme is using the custom menu and is not falling back to wp_list_pages or wp_page_menu? When using View Source the classes on each menu LI should be like: menu-item menu-item-type-post_type menu-item-object-page menu-item-123 – starting with “menu-item”. If not, its not using the custom menu. I’d start by confirming that is working.

    Check View Source and confirm the theme is using the custom menu.

    Thread Starter djhomick

    (@djhomick)

    If you happen to be using iThemes Builder, you have to edit the Navigation Module in each Layout to tell it to use a custom menu. Just a thought. ??

    I have same issue. I checked my source code: <li id=”menu-item-273″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-273″>Account Login

    But this does not open in new tab/window. I am using WordPress 3.2.1

    Please advice.
    Thank you.
    Priyanka

    Hi Priyanka

    At the top of the Custom Menus dashboard page click Screen Options.

    Put a check in Link Target and CSS classes. Now a Link Target field is added to every menu item. Set the ones you want to “open in a new window”.

    Hi,

    I have already done that. But its not opening in new window/tab. I do see target=”_blank” in source code.

    Please advice.

    Thank you.
    Priyanka

    Is that happening in more than one browser, and on more than one computer?

    I tried Mac OS, Windows XP and Vista. I tried it on FF, IE, Safari and Chrome.

    Perhaps there is some javascript overriding the intent of opening in a new tab/window? Can you post a URL of the page with this issue?

    May be. Is there any particular java-script i should be looking for? Unfortunately, I can’t share the url. Its for a client. But I would really appreciate any insight on this issue.

    Thank you.
    Priyanka

    target="_blank" is standard HTML.

    If you use it, it opens links in a new window or tab, no question, that is how it works. Someone can configure a browser to override that action, so the browser doesn’t open it in a new tab or window. That is why I asked you if this is happening on more than one browser.

    Your answer was it happens in every browser on every operating system. That eliminates browser settings as a possible cause.

    Since this is not happening on any browser on any computer something is overriding this normal HTML action. A likely source of it is javascript or jQuery code.

    Without knowing a URL, where I could see the code that is running, its not possible to tell you what code is causing this, or even if this is the cause. You will have to look at the code in your theme and look for yourself.

    One way to override target="_blank" would be to either change the target to something else on all occurrences of `target=”_blank”. Another would be to simply remove that attribute altogether. If this was done in jQuery, the code would likely start with
    .attr('target' or .attr("target"
    However there are many ways it could be done, not just with that code and not just in jQuery.

    I can’t really help you beyond this given the information you are able to post. You have to review all of your code. Try disabling any javascripts one at a time and see if the links start opening in new tabs/windows.

    If you don’t already use it, download and install the Firefox Firebug addon. That is how I’d review your code if I was looking at your site.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Would like custom menu option (url) to open in a new window’ is closed to new replies.