custom_page.php – set Main Menu
-
I would like to dynamically set the Theme’s top level Main Menu on pages that use the Custom Page Example template and have a CustomField MainMenu.
I have two custom menus – Main and CareerPortal. In WordPress administration Menu – Menu Locations the Theme Location Main Menu is set to Main.
On some pages, the Page Attributes – Template is set to Custom Page Example. I have created a Custom Field called MainMenu with a value of CareerPortal.
I have moved custom_page.php from the Customizr folder into the customizr-child folder (I installed the child theme using the plugin).
As a test, I have inserted a ‘wp_nav_menu’:
wp_nav_menu( array( 'container' => 'none', 'container_class' => 'menu-header', 'theme_location' => 'Main Menu', 'menu' => get_post_meta( $post->ID, 'MenuName', true) ) );
into the following hook and it works
<?php do_action( '__before_main_container' ); ##hook of the featured page (priority 10) and breadcrumb (priority 20)...and whatever you need!?>
but of course it is just sitting there under the breadcrumbs ??
I do not know how to place it in the Main Menu section of the Theme so it replaces Main and inherits the style, features, and functions.
Hopefully somebody has already accomplished this and can assist? Here is a link to the test page so you can see how it renders:
https://a11.60e.myftpupload.com/careers/
To summarize, I want Main menu starting with About Us in the Main Menu section of the Theme to be replaced by the CareerPortal menu starting with Rewarding Work that is currently rendering below the breadcrumbs on Pages that use the Custom Page Example template.
Thank you!
- The topic ‘custom_page.php – set Main Menu’ is closed to new replies.