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

I want to create the ghost page /foo/ so that it appears in the list of pages, but is unclickable and has no content.

An example use of this is that in my menu it displays the pagename foo and when you hover it, it displays the subpages (which are "real" pages) bar and baz. The URLs of them would be /foo/bar/ and /foo/baz/.

I figured I could simply remove the <a> tags of foo in Javascript and put a redirect in the /foo/ page. but that doesn't feel right. What would be an elegant/serverside solution for this problem?

share|improve this question
Please show us your code. Are trying to that in a menu? If so, in which menu? Is this admin or theme facing, etc? This question needs a huge edit and lots of additional information. – kaiser Sep 30 '13 at 12:36

You can do it this way. check for a unique class for the page in the menu or add an unique class. you can do it by checking CSS classes under screen options in the menu edit page.

lets say the class you added is ghost-page

Then in the js file

    jQuery('.ghost-page').on('click', function(e){

But the page will still be accessible by home_url()/page-slug but the above will disable the click event from the menu for this page.

But if you don't want a page to exist then, add a custom link to the menu with # in the url and add the css class and label as foo, by doing so there wont be a page to link with and the above js code will disable the click event.

enter image description here

Hope it helps!

share|improve this answer
Hmm, if this is the only solution I'm a bit disappointed in the flexibility of Wordpress. – Joren Sep 30 '13 at 12:02
I guess I have found a better solution. I have improved the answer. pls check the bottom of the previous answer. – Maruti Mohanty Sep 30 '13 at 12:12
You can't put a # in the URL. – Joren Sep 30 '13 at 13:22
You can while creating a custom link for a menu. – Maruti Mohanty Sep 30 '13 at 13:25
Added an image in the answer... Hope it helps – Maruti Mohanty Sep 30 '13 at 13:36

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.