- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I’m embarrassed that I can’t figure this out on my own, but I don’t have a php background. I have a code block in wordpress to put in the submenu in the header depending on the parent page, but I don’t want it on the home-page. How would I code it to not show a sub-menu on the home page? Or any other particular page, for that matter?
Try this. You can just say if is_page then the page number. So basically you are only showing the submenu on certain pages. The last else statement just puts your main menu on all other pages.
wp_list_pages('title_li=&include=5,7,11,20&depth=-1');
} elseif (is_page(/*either page number or page slug name*/) ) {
wp_list_pages('title_li=&include=25&depth=-1');
} else {
wp_list_pages('title_li=&include=32,145&depth=-1&sort_column=ID');
} ?>
Thanks, but what I’m trying to write is a statement that doesn’t default to a sub-menu, I want the default to return nothing.
then that would be
wp_list_pages('title_li=&include=5,7,11,20&depth=-1');
} else {
\no sub menu
wp_list_pages('title_li=');
} ?>
That didn’t work, but I figured it out. The last line before closing tag:
//no sub menu displayed
wp_list_pages('echo=0');