Custom menu per page
Home › Forums › Pro Support › Custom menu per page
- This topic has 14 replies, 2 voices, and was last updated 6 years, 2 months ago by Anonymous.
-
AuthorPosts
-
February 2, 2018 at 2:47 pm #68724Anonymous
I’m wondering if it is possible to change the menu options based on the page that is being accessed?
Thanks so much,
MatthewFebruary 2, 2018 at 3:05 pm #68737Peter FeatherstoneParticipantHey Matthew,
Sure, using the shortcode you can do this, a guide is below:
https://responsive.menu/knowledgebase/using-the-shortcode/
Not all options can be changed based on the page, but there are a few that can.
If you want a full list of options you can look in the
default_options.php
file for a list but again not all will work as options.Hope that helps
Peter
February 2, 2018 at 8:51 pm #68736AnonymousI’m a bit confused about the syntax…
The article you linked to indicates that the shortcodes should work when placed on the page itself (unless I misread). Doing so only places the shortcode on the page as text.
May I ask the exact syntax if I desired to place this in header.php?
As an example:
<?php echo do_shortcode(‘[responsive_menu_pro menu_to_use=”menu1″ menu_title=”example”]’); ?>;How does header.php know which specific page this code would apply to? OR is there a header.php associated with each page that I’m simply unaware of?
Thanks so much for the help :),
MatthewFebruary 2, 2018 at 9:52 pm #68735AnonymousI was in error and figured this out by placing the proper short code on the pages I want.
New problem though!!
I have a conflict:
I used this code to have the menu only show when users are logged in:
if(is_user_logged_in()) echo do_shortcode('[responsive_menu_pro]');
However, the custom menu for the specific pages I want will no longer show, or even open for that matter. How do I fix this conflict?
February 5, 2018 at 10:15 am #68734Peter FeatherstoneParticipantHey Matthew,
What do you mean by a conflict?
You will need to combine your if statements, otherwise it sounds like you are trying to put more than one shortcode on a page.
Can you advise if that is the case?
Peter
February 5, 2018 at 1:23 pm #68733AnonymousHere is the problem, if you enable short codes, the plugin removes all menus until a short code is used. A nice feature would be to have a drop down list that we could select a default menu for pages that do not have short codes. That way I don’t have to place a short code on every single page, you know what I mean? OR is there a way to do that, and I just know?
Keeping the above in mind, can you suggest a php code? If no shortcode on page, then use menu ‘example’… is such a thing possible?
February 6, 2018 at 9:27 am #68732Peter FeatherstoneParticipantHey Matthew,
You shouldn’t have to place the shortcode on every single page.
You normally just add it to your
header.php
file. I haven’t heard of someone putting it on every page, because as you say that would be very annoying and time consuming.Is there a reason you are doing it on every page?
Peter
February 6, 2018 at 12:21 pm #68731AnonymousI need a different menu for about 50 pages. Maybe I’m misunderstanding something or doing something wrong?
February 8, 2018 at 12:24 pm #68730AnonymousI needed lots of different menus for different pages, and only to be displayed when logged in.
For others that might be interested, here is what worked for me, don’t know if it’s “proper” as I’m new at this, but it did work:
<?php $pagerange1 = range(310, 360); //page id range variable $pagerange2 = range(1000, 1400); // page id range variable if (is_user_logged_in() && is_page( $pagerange1 )){ //if user is logged in and on pagerange1, run menu1 echo do_shortcode('[responsive_menu_pro menu_to_use="menu1"]'); } elseif (is_user_logged_in() && is_page( $pagerange1 )){ //if user is logged in and on pagerange2, run menu2 echo do_shortcode('[responsive_menu_pro menu_to_use="menu2"]'); } elseif (is_user_logged_in()) { //if user is logged in, run main menu echo do_shortcode('[responsive_menu_pro menu_to_use="main"]'); } ?>
February 9, 2018 at 9:27 am #68729Peter FeatherstoneParticipantHey Matthew,
Requiring 50 different menus unfortunately is going to end up with quite a bit of messy code due to the nature of what you are trying to do.
I think the most I’ve heard of before this was only 3 which is why I hadn’t quite realised how many you actually need.
However, now looking at your code above it seems you only have 3 different menus or is there extended code somewhere.
Your solution looks quite elegant, so well done!
Peter
February 9, 2018 at 1:20 pm #68728AnonymousI’m using your menu in a unique way I suspect. I’m not using it as a “menu” but more as a course navigation tool. I have pages set up for a course, each course has 10 topics (for example). If a person is on topic 5, I want them to open the navigation menu, and be able to select other topics. I’ve added a back link in each menu to take them to the homepage. I’m currently at 3 page ranges deep, but as you can imagine… depending on the amount of courses I have, this might get crazy. Haha.
Alternatively, I was thinking we could use the is_tag function, and apply a unique tag to every post in a course. I’m still learning and trying different things. 🙂
February 10, 2018 at 4:19 pm #68727Peter FeatherstoneParticipantHey Matthew,
It does sound quite unique.
Can’t you just have a normal menu that has the topics and courses in a normal menu structure and have the menu open on just the current parent page?
I may have misunderstood what you are doing though.
Peter
February 10, 2018 at 7:29 pm #68726AnonymousYou could do it that way, but I don’t find it as aesthetically pleasing depending on the size of the menu. It means you would see everything else, other than just the course navigation. I was kinda going for a cleaning look, whereby one “entered” into a course. The menu than displays only information relevant to that specific course. Does that make sense? 🙂
February 12, 2018 at 10:02 am #68725Peter FeatherstoneParticipantHey Matthew,
Yep that makes complete sense 🙂
Peter
-
AuthorPosts
- The topic ‘Custom menu per page’ is closed to new replies.