For every website project, i make the wordpress admin custom for the client. Right now, i want that the client only has access to add subpages.

I have a main navigation on the website. I want that the main navigation is fixed, so the client can not add pages to the navigation. But the client can add subpages to the current pages in the fixed main navigation.

I googled it, but i can't find a solution. I know i can show menu items on a specific id. So i can make the main navigation fixed.


<?php wp_list_pages('include=7,13,26,35&title_li=<h2>' . __('Pages') . '</h2>' ); ?>

But, does it show the subpages id's thats below the page id? And is there not a cleaner way? Because with this solutation the client has still access to create pages. I only hide the created pages on the front website.

Hope someone can help me.

Many thanks,

  • 1
    Can I ask why? Seems like an awful lot of trouble to go to when one can just use wp_nav_menu and let the client change the menu as they want for no additional effort – Tom J Nowell Apr 8 '13 at 8:56
  • @TomJNowell The reason why is that some clients don't have the talent to manage their website with an easy open source cms like Wordpress. Some clients surprise me how they can f*ck up a website with the options they have (; Thats the reason why i want to block or hide all the options that the client don't need to use. – ElBrm Apr 8 '13 at 9:32
  • Then you just need to make sure either they don't get a role higher than editor, cant see those options pages, or that your contract is robust enough to allow them to do all this ( with the caveat that it is a very expensive thing to do ) – Tom J Nowell Apr 8 '13 at 9:57
  • I'm doing things like that. Thats the reason why some clients surprise me (; I try to hide everything they don't need to use. This subpage problem is one of them, but if its not worth it, i just need to inform the client. – ElBrm Apr 8 '13 at 10:18

wp_list_pages simply lists pages. It isn't a menu and doesn't use the navigation menu APIs. For what you want you'd need to do several queries to find the subpages of those page IDs, so in your case 4 queries, and you'd need to do 4 wp_list_pages calls, and a manual query to get the top level pages. This will not be fast, and is wasteful, kludgey, and a bad idea.

So instead you should be using wp_nav_menu. Use a standard nav menu, if your client modifies this then charge them to put it back ( serves them right, they were warned, but it is their site, and they paid for it, so why shouldn't they be able to? ).

With a standard nav menu you can add non-page items, rearrange items, and submenu items don't have to follow the page structure.

  • Allright. Thanks for you advice. If there isn't an easy clean solution, maybey it's not worth it. – ElBrm Apr 8 '13 at 9:27
  • It's not hard, it's just a bit longwinded and not ideal, e.g. something similar to this:foreach ( array( 7,13,26,35 ) as $id ){ echo get_permalink($i); echo '<ul>'; wp_list_pages..... etc – Tom J Nowell Apr 8 '13 at 10:00
  • Yes. Well, if it's longwinded and not ideal, it's not worth it for me. Thanks for the info! – ElBrm Apr 8 '13 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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