Hi there, I´m using the following customizable responsive menu:
http://peterfeatherstone.com/wordpress/responsive-menu/faq/how-do-i-show-different-menus-on-different-pages/
My cuestion is how can I write php code, is there something similiar to Css editor or Custom CSS??? but for PHP???, or how can I set the code there (page I paste) is written.
Thanks for ur help
Hi Artvaz
The PHP outlined at the link provided is targeted at a much deeper level of integration. For that you’d be working in a child theme and editing the Vantage template files and or adding your own. If you’re not at that level then it’s best to work with a plugin. I saw you chatting to Magus about this earlier. Did you try https://wordpress.org/plugins/if-menu/. Was there a problem with the Vantage mobile menu?
yeah Andrew thanks god you are here ahahah, look for some reason the vantage mobile responsive menu is not working, do u think thats happening due to now I have different menus deppending on the page??
One moment, let me just test out If Menu quickly on my local installation.
Alright, your have to know that now I´m using Zen Menu Logic, as Magus Recommended me
Cool, thanks, let me test that now. One moment.
Zen Menu Logic – great looking plugin but unfortunately doesn’t work with the existing Vantage Mobile Menu setup.
I’m still looking around. Be with you ASAP.
Thanks I´ll be waiting
Give this plugin a try, I’ve used it in the past:
https://wordpress.org/plugins/menu-items-visibility-control/
Once activated go to Appearance > Menus, select your main menu and edit an item. You’ll see a visibility field. There you can enter a PHP conditional argument. The ones you need are easy to learn. For example:
That will display this menu item on all pages except the cart page. ‘cart’ refers to the page slug name. The slug is the url if you’re using pretty permalinks.
Similarly, you could say:
By removing the ! we’ve changed it to say, display this menu item ONLY if the page is ‘cart’.
Give it a go.
Reference conditionals: http://codex.wordpress.org/Conditional_Tags. Super powerful once you get into it a little.
Ok Andrew, how can I set to show it in more than one page???
I was imagine like this:
is_page( ‘cart1’, ‘cart2’, ‘cart3’, and so on )
am I right???
Try:
Check out the is_page section here: http://codex.wordpress.org/Conditional_Tags. Some cool examples.
or like this???
is_page( array( ‘cart1’, ‘cart2’, ‘cart3’, and so on ) )
Yeah, that’s it. Just be sure that your inverted commas are like mine in the code block. Plain text.
ohh sorry my mistake yeah I just read that thanks Andrew I will give it a try
No worries, bit of cross over as we both have the thread open etc. Let me know how it goes. A very basic plugin, I know, but if it does the job then it’ll all be worth it.
Andrew I was wondering if as in the document you give me it says you can use Page ID´s, and I write as follows
is_page(array( 1658, 1394 ))
corresponding to:
qpuntto.com/puebla
and
qpuntto.com/puebla/bares
but it kinda not worked.
It should work. The conditional says: Only display this menu item if we are on page 1658 or 1394.
Which menu item did you add this conditional to?
Toluca Menu>Restaurantes
Restaurantes is the item I added
I’m not seeing a menu added. Can you confirm that Appearance > Theme Settings > Layout > Masthead Menu is NOT set to Empty Menu.
If you’d like, send a set of temporary login details. Send to: [email protected]. Thanks.
it is set as Default Menu, ANdrew, which menu among the 3 possible I have has to been set up as Primary menu?? do you think thats the problem???
One menu must be set as primary. We must only make edits to that one menu. This plugin is different to Zen. With this plugin we’re listing all our pages in one menu and then editing each item to say when it should be displayed.
That sounds like the break through we needed.
This is a private message.
I think just a small problem with the bars page ID. To get the ID just edit a page and check the URL. puebla was correct. Check the two pages now. On those two pages the restaurant link will show.
Let me see if I understand and correct me if I´m wrong please
if the visibility field is empty what happen?, it will show all the items???
What your statement says is:
“If the page is puebla or bares then show the restaurant menu item. On any other pages that is not peubla or bares, don’t show the restaurant menu item.”
Try explain what your end result must be and I’ll help with the conditional.
I resolved it already, my mistake, for some reason if one of the items wasnt mentioned in other item, it shows even it was set to show other pages, already working thanks Andrew! you are the best thanks for ur time!!
Awesome! Glad to hear you were able to resolve. As I mentioned, very basic plugin, nothing fancy but there is still plenty of power once we get our head around inserting the correct PHP conditionals. If you need help in the future, please, let us know.
Cheers for now :)
Andrew I´m trying to set the menus also for my posts (http://qpuntto.com/resenastolucametepec/el-cafe-mas-perro-bulldog-cafe/) but it is not working
im doing it as follows:
What am I doing wrong???
and for example the parent “post” where you can see all of my posts is this one:
http://qpuntto.com/resenastolucametepec/
so I dont know which is its ID
Sorry, I’m not following. When you say Set the menus also for my posts could you explain what you’re trying to do. Thanks :)
I´m using
Reference conditionals: http://codex.wordpress.org/Conditional_Tags. Super powerful once you get into it a little.
so I can have different menus depending on the page, but now my problem is that I also need to have different menus depending on the post, so I´m using the following code to make the conditional menu:
the following post is ID 2166
http://qpuntto.com/resenastolucametepec/el-cafe-mas-perro-bulldog-cafe/
Ahh right, thanks for reminding me.
is what you need to be using for posts.
http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page
yeah I´m using that way look like this:
so what I´m saying is:
I want the menu to appear on PAGES 1571,1667,1662 and on POSTS 2166 2077
I’m not sure this plugin can handle two statements, I haven’t tested that yet. Perhaps try saying this instead:
It was not posible, I think I will have to think on another way of redirectig my clients thanks Andrew for your time
I can get it to work with OR instead of AND. Try this:
very useful thanks again!!!!
For sure :)