I can use exclude to exclude specific pages from the menu, but this should be hardcode. All sections (pages) that use the Template parallax should be exclude from the list of menu items. As you can see in the visual, page 2 should be exclude from the menu, ONLY from the menu, the section should still visible on the page.

It would be great, if there is a way to exclude these pages from the menu, but still use the order of the menu to position these sections on the right place, the same as the other ones that are not containing ads. Only the items that are exclude, should not display in the list of menu items.

Good to know is that each "advertising" section has the class parallax. And also the template has the header name in it (see below).

So if there is a way to code a function that will exclude these sections with the class parallax, would be great. There is a way to exclude pages hardcoded by putting in the pageID, but I am searching for a way this will be automatically handled within WordPress, by looking for the class parallax or something else...

Header of the parallax template:

<?php
/*
Template Name: Parallax
*/
?>

If there are questions, I would like to hear from you. Hope someone can help me out! Thanks in advance. Have a good evening!

1 Answer
1

Exclusion has to be based on something connected to the pages that is stored in the database. The only thing template-related stored in the database is the filename of your Parallax template, which is stored in post meta under the key _wp_page_template. You could query for pages that either don't have the key _wp_page_template, or if it does have the key, that it doesn't equal whatever the filename of the template file is.

Thank you for your answer. This looks like to work, but the only thing is that this will work for which page is showed, am I right? What I am searching for is, the way to exclude only the menu item in the menu if the item has the page template parallax, but it should still display the page. So all pages should be visible, only the ones with a custom template parallax should not appears in the menu item list.
– CasperNov 19 '15 at 14:57

It excludes all pages with the parallax template, the page currently being viewed is irrelevant. See the Custom Fields section for WP_Query for more details about meta queries.
– MiloNov 19 '15 at 16:32

Hmm this is not working as expect, because this array of arguments is used for the loop to walk through al pages. That is working correct, only what I want is to doesn't show the sections inside the menu.
– CasperNov 19 '15 at 18:05

Did you change parallax.php to the filename of your template file?
– MiloNov 19 '15 at 18:19

Yes, but your arg array should be added to the page loop, am I right? And parallax.php is saved in a folder templates.
– CasperNov 19 '15 at 18:21