Hello,
I write on behalf of my client Kenneth Reed and I need help with setting up a menu.
I will try to explain the workflow:
On the Home page, I need to have only one item in the menu (Explore - see the attachment - image 01) as a dropdown which lists continents. When you select one of the continents it will lead you to a continent page where the menu will have two items (continents and countries). (See the attachment - image 02).
Again, when you select one of the countries from the listed countries related to this continent it will lead you to a country page where the menu will have 3 items (continents, countries, and regions). (See the attachment - image 03).
Similar to the above, when you select one of the regions related to the displayed country it will lead you to a region page with a menu with 4 items (continent, country, region, and destination).
The final level will be the attractions page (menu with 5 items - continent, country, region, destination, and attraction).
Any ideas for solving this problem?
Thanks
What is the link to your site?
hidden link
Hi,
I've set your next reply as private so that you can share the credentials for the admin area.
Please also include a link to any page where this menu can be seen.
Note: No changes will be made on your website, but please make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing the credentials.
I'm afraid, there is no direct feature to conditionally show/hide the menu items based on the post-relationships, which is why some workaround will be needed in this case.
Can you please create a navigation menu, with any example items as shown in the screenshots? Once the navigation menu is in place, I'll be in a better position to suggest the best way forward.
regards,
Waqar
Hello,
the navigation should be like some kind of filter. Can you check this demo hidden link scroll down to search the houses? When you select the States the Cities listing change depends on what state you select.
Thanks for writing back.
Those select options that you refer to are part of the post view's search filter. You can learn more about those through this guide:
https://toolset.com/documentation/user-guides/views/front-page-filters/#2-6-filtering-posts-by-their-ancestors
It is important to note however that those search filters can only be used inside the search form of the view and not as part of the navigation menu. Also, as a result of the selection, the user won't be redirected to the relevant listing automatically. The selection will only narrow down the results so that the visitor can click on the desired one.
( similar to how the search form and the results work at hidden link )
If you're fine with using the search form and results instead of a navigation menu from the screenshots, then yes this can be used and you can show a common view with a search form on all your pages so that visitors can select the desired options and then pick the final listing.
If you'd like to stay with the initial idea of navigation menus, then it will require some customization and understanding of WordPress functions like:
- wp_get_nav_menu_items
https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/
- wp_create_nav_menu
https://developer.wordpress.org/reference/functions/wp_create_nav_menu/
- wp_update_nav_menu_item
https://developer.wordpress.org/reference/functions/wp_update_nav_menu_item/
Here is a thread with good usage example of programmatically generated navigation menu items:
https://wordpress.stackexchange.com/a/44739
To retrieve the related post items to be used in this dynamic menu, you can use the "toolset_get_related_posts" function from "Post Relationships API":
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
For more personalized assistance around custom code, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
Another alternative, which is less dynamic though, is to use third-party conditional logic plugins for the navigation menu items:
hidden link
https://wordpress.org/plugins/if-menu/
https://wordpress.org/plugins/conditional-menus/
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Ok, thank you Waqar, it seems I must hire someone.
Also, can you check the Footer, why I get duplicated results? Where I was mistaken?
Thanks
I've checked the views used in the footer of the website and noticed that a view named "Footer listing Europe - country" is being nested in another view "Footer listing - Europe".
But in the "Query Filter" section of the child view ( Footer listing Europe - country ), France is set as a specific country to get the related posts from.
( screenshot: hidden link )
As a result, the parent view's output repeats two times (because there are two countries connected to Europe), but for both repetitions, results from France are shown.
To make this child view get results based on the parent view's country, please select "The current post in the loop" option in the "Query Filter" section.
Note: I also noticed a typo in "Loop Editor" of the view "Footer listing - Europe".
( screenshot: hidden link )
Please let me know how it goes and for a new question or concern, you're welcome to start a new ticket.
Thank you, Waqar for your help.
Footer is now ok.
You can close this ticket, please.
Thanks for the update and glad that it is working now.