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

A client of mine has a WP multisite network of sites which all use the same template. This template uses wp_page_menu. I just added a mobile version of the template by using a certain plugin. It will use the same pages as the desktop version of the website, but the client has requested a different landing page.

The problem is that if I create a new page to facilitate this landing page, it will show up in the code generated by wp_page_menu. Since all sites in this network uses the same template and the page will have different page IDs on different sites, I cannot exclude it manually in the wp_page_menu function.

I was thinking that if I could exclude the post by title or category name instead of by ID, this might work. But I don't know how to do that. Please help?

share|improve this question
up vote 1 down vote accepted

How about using get_page_by_path(), then using the ID from the returned object in an exclude filter?


function my_nav_exclude_pages( $args = array() ) {
  $homepage = get_page_by_path('my-page-slug');
  $args['exclude'] = join( ',', array( $args['exclude'], $homepage->ID ) ); 

  return $args;
share|improve this answer
This works great, thanks a lot! :] – user5028 Jun 1 '11 at 21:20

Your Answer


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