Search result based on menu category
-
Hi All,
i’m looking for two pieces of code that can help me with the following:
I got posts and pages with a custom menu. These posts/pages got a custom template activated. The templates contains the menu for the specific posts and pages. This way i can order pages/posts in two different categories.
Now i like to change the search function; the search output should be based on the active custom menu category.
I named menu 1: Benelux and menu 2: International
1: First peace of code needs to be for the searchform.php
The code should look at the current active menu(category) and the search result should be based on the active menu.If the menu is for example “Benelux” then the search result should only display pages/posts from the custom taxonomy that i made <input type=”hidden” name=”location” value=”benelux” />
Or if the active menu is “International” then display pages/posts from the custom taxonomy <input type=”hidden” name=”location” value=”international” />I found the following code to get the menu category…not sure if this is useful..
(wp_nav_menu( array( 'menu' => 'benelux' ) )
2: Second peace of code is needed for the search.php (header).
Because if the output should work correctly than we also need to change the menu for this search result page. Default the search.php uses the main menu.So the following code needs to see if the pages/post contain taxonomy benelux or international and change the menu accordingly.
It would just be really awesome if this is possible.
Greatings,
Taro
- The topic ‘Search result based on menu category’ is closed to new replies.