WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In this website:


I have a navigation menu taken from the twentyten theme. I want to make some links clickeable and some not (some don't have to behave like a link). I have accomplished this with some CSS but it doesn't work in all browsers.

The links are dinamically generated with:


Any suggestions?

share|improve this question
why did I get a down vote? – janoChen Apr 30 '11 at 11:16
probably because its not related to WP – Ashfame Apr 30 '11 at 11:24
@Ashfame the navigation bar (which uses Wordpress' php functions) of the twentyten theme is not related to Wodpress? – janoChen Apr 30 '11 at 11:38
your question is about how to make links not behave as links. the source of the links is not that relevant, surely. – anu Apr 30 '11 at 11:43
if you have to change how WP do something, then only it can be called WP related. If you are looking for a CSS/JS fix, stackoverflow.com might be better. Check my answer (js) to see if that does what you need. – Ashfame Apr 30 '11 at 11:47
up vote 1 down vote accepted

Create a custom menu item in the admin panel with a dummy URL, foo.com or whatever. Add it to the menu, then delete the target URL and save. The menu item will be rendered without an href attribute and will be unclickable.

share|improve this answer

Via the menu admin in WordPress you can add a custom class, say no-link, to the links you want to be unclickable. You may need to enable the custom class field via the display options.

Here's two ideas, based on jQuery. Note that the links will still be there for those with JavaScript disabled.

$(document).ready(function() {

    // Your navigation ID
    var $nav = $('#navbar');

    // A. Completely remove the anchor element and replace it with a span
    $nav.find('li.no-link > a').wrapInner('<span/>').find('> span').unwrap('a');

    // or

    // B. Remove href attribute so nothing happens on click
    $nav.find('li.no-link > a').removeAttr('href');

share|improve this answer

Use js to cancel the link behavior by returning false on click. This should work:

        return false;
share|improve this answer

If you don't want a link to behave like a link, then don't make it a link - ie remove the <a> </a> tags.

share|improve this answer
the linksa re dinmically added with wp_nav_menu – janoChen Apr 30 '11 at 11:39
then don't use wp_nav_menu – anu Apr 30 '11 at 11:43
I can't add them directly. The website if for a client. He must be able to add new links to the menu via wp-admin. – janoChen Apr 30 '11 at 11:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.