I'm struggling to finish my first Word Press Theme and I've stumbled upon baffling problem: one of my menus - in this case a footer menu - is not visible.
This the actual code I have:
</div><!--#main-->
<footer>
<div class="bottom">
<nav><?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'footer-menu', 'theme_location' => 'footer-menu', 'menu' => 'Footer Menu' ) ); ?>
</nav><!--.bottom nav-->
<div class="info">whatever ©2015</div>
</div><!--.bottom-->
<?php wp_footer(); ?>
</footer>
</body>
</html>
And this is what Chrome's view-source is showing in appropriate place:
<div class="bottom">
<nav> </nav><!--.bottom nav-->
<div class="info">EEAC ©2015</div>
</div><!--.bottom-->
Meanwhile, I am 100% positive I got right names in the Dashboard.
Other menus I've got are working. There are 3 more of them, all made using very similliar code. No problem there. Just this one.
CSS is also very similliar, no ground breaking changes, so that's not the problem I think.
Have You got any idea what might be causing the problem here?
EDIT: It does however show up on the single.php and page.php. Only place it's not included is main page so far.
Try removing:
'sort_column' => 'menu_order'
Related
My client's WordPress website I created and selected a menu for mobile.
It's good on desktop but menu items are not showing on mobile.
Here is website link http://biz236.inmotionhosting.com/~ifbbpr5/
In your <div class="mobile-menu"> no items is generated.You should call your menu to that div in your header.php.
<div class="mobile-menu-area">
<div class="mobile-menu">
<?php echo wp_nav_menu( array('menu' => $atts["your-menu-name"] , 'container' => '', 'items_wrap' => '<ul id="your-ul-id" class="your-ul-class">%3$s</ul>' ));
?>
</div>
</div>
I'm trying to create custom website theme for Wordpress and I ran into a bit of a problem. I use two absolutely same menus in my header and footer part of website.
Calling
wp_nav_menu(array('theme_location' => 'header'));
in header.php works well, the menu prints out without any problem, but if I do the same in my footer.php file, the menu doesn't print and var_dump(wp_nav_menu(array('theme_location' => 'header'))); prints false.
I've tried some workarounds that I found on Google with modifying the functions.php file, but none of them helped me resolve that problem. My functions.php file now consists of only one line
register_nav_menus( array( 'header' => 'Header menu', 'footer' => 'Footer menu' ) );
and yes, I tried to use
wp_nav_menu(array('theme_location' => 'footer'))
as well, with same result. If I call the same function from header.php
wp_nav_menu(array('theme_location' => 'footer'))
the menu works good.
You have registered you two nav menus correctly. I always do that within my initial theme setup hook that gets hooked to the after_setup_theme hook. So I would do something like this in your functions.php:
function pietergoosen_theme_setup() {
register_nav_menus( array(
'header' => 'Header menu',
'footer' => 'Footer menu'
) );
}
add_action( 'after_setup_theme', 'pietergoosen_theme_setup' );
Keep in mind, you don't have to do it this way. The following also works
register_nav_menus( array(
'header' => 'Header menu',
'footer' => 'Footer menu'
) );
You should now see the two menus in the backend under "Appearance > Menus > Manage Locations" (Only if a menu exist)
For the sake of the footer menu, add the following code in your footer where you need to display the menu:
<nav id="footer-navigation" class="site-navigation footer-navigation" role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'footer', 'menu_class' => 'nav-menu', 'fallback_cb' => false ) ); ?>
</nav>
At this stage nothing will be displayed, and I think this is where you also get stuck at. The reason for this is that there aren't any items assigned to the menu, and if there are nothing assigned to a menu, then nothing will be displayed. So we have to insert something to be displayed.
In the backend, go to "Appearance > Menus > Edit Menus". In the "Menu Name" field, enter a name for your menu and click "Create Menu". You will now be able to add the menu in the menu screen.
You can now choose items from the left hand side to insert into your menu. You can also set the location of the menu, in this case in the footer. I've selected to display the categories in the footer. Click "Save Menu" when done.
You should now see your nav menu in the front end.
You just have to add styling to your nav bar now. You will do exactly the same for the header nav menu, accept you will add the call to the menu in the header.php. I hope you find this usefull.
So I’m producing my second WP theme and I’ve struck a problem. As well as the standard Nav menu at the top of my pages, the Footer element contains three individual sub-menus that can be loaded with individual entries. These are broken into three areas: Product Range, Industry Type and Services. The source code on footer.php is thus:
<div class="col-sm-3" style="float:left">
<h3>Product Range</h3>
<?php wp_nav_menu( array( 'footer' => 'product-range', 'container_class' => 'footer-menu' ) ); ?>
</div>
<div class="col-sm-3" style="float:left">
<h3>Industry Type</h3>
<?php wp_nav_menu( array( 'footer' => 'industry-type', 'container_class' => 'footer-menu' ) ); ?>
</div>
<div class="col-sm-3" style="float:left">
<h3>Services</h3>
<?php wp_nav_menu( array( 'footer' => 'services', 'container_class' => 'footer-menu' ) ); ?>
</div>
In functions.php I have included:
*Add footer Menus
*/
function register_my_menus() {
register_nav_menus(
array(
'product-range' => __( 'Product Range' ),
'industry-types' => __( 'Industry Types' ),
'services' => __( 'Services' )
)
);
}
add_action( 'init', 'register_my_menus' );
The output to all three menus is identical, and it is not what I want:
Product Range
COVID19 Policy
Latest and Greatest
About Us
Contact us1
Customer Service
Our Guarantee
Industry Type
COVID19 Policy
Latest and Greatest
About Us
Contact us1
Customer Service
Our Guarantee
Services
COVID19 Policy
Latest and Greatest
About Us
Contact us1
Customer Service
Our Guarantee
The top two items I added in the CMS, the remainder are automatically generated form somewhere else?
What gives?
I have done this million times before and I have no clue what is going on now. I've had one navigation menu, client asked me to add another one and the whole thing collapsed. After I added second navigation, added some pages to it and assigned it to the right location, the first menu appears in the location of the second one, and in the location of the first again it is the first menu.
Here is my register nav code in functions.php:
register_nav_menus( array(
'primary' => __( 'Top navigacija', 'wpfme' ),
'above' => __( 'Above header', 'wpfme' ),
) );
Here is the placement of both in the header.php file:
<div class="left" id="kkk_top">
<p><?php bloginfo('name'); ?> <?php wp_nav_menu( array('menu' => 'Above header' )); ?>
</p>
</div><!-- #kkk-top -->
<div id="main_navigation">
<?php wp_nav_menu( array('menu' => 'Top navigacija' )); ?>
</div><!-- #main_navigation -->
I should also add that menu that now appears in the Above header location is wrapped in the div with the dynamic id it had when there was no second navigation, and menu that now appears in the Top navigacija location is wrapped in a div with a new dynamic id.
I just deleted the second menu and created it again, placed it in the new theme location and now it s all cool... when in doubt always reboot :)
I have searched and searched. I can't find how to remove an empty select menu at http://propelyourteam.com
CSS
.select-menu, .select {
display: none;}
.menu-main-container {
position: relative;}
Menu Php
<div class="header-right">
<?php wp_nav_menu( array( 'theme_location' => 'header', 'menu_id' => 'nav', 'menu_class' => 'nav-top', 'container' => '', 'container-class' => '', ) ); ?>
<div class="clear"></div>
</div>
<div class="clear"></div>`
In your custom.js file on line 69 you're creating what looks like a mobile menu using the Mobile Menu plugin. You can find more information on how to use that plugin here. (It needs to have some parameters passed to the function in order to properly select your navigation menu items).
However if you don't want to use this plugin you can remove line 69 and would probably also want to stop it from being included in your functions.php.
I can't seem to get my sub-menus to display.
I've gone to: Home » Administration » Structure » Menus
Then, I've edited the parent menu and checked the tickbox that says "Show as expanded" - but still nothing.
The code on my page.tpl.php page for the navigation I'm referring to, is as follows:
<?php
if ($page['navigation'] || $main_menu):
?>
<?php
print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'nav',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
));
?>
<?php
print render($page['navigation']);
?>
<?php
endif;
?>
What am I doing wrong?
Any help would be GREATLY appreciated.
Make sure that the parent menu "Show as expanded" attribute is checked.
Go to admin/structure/menu/item/MENU_ITEM_ID/edit, and check "Show as expanded"
Instead of using the $main_menu variable, you can use the main-menu block, which is generated with the menu.
If you put the "Main menu" block into the "Navigation" region at admin/structure/block, print render($page['navigation']) in the page.tpl.php will print out the complete menu, including its sub menu items (children).
Just make sure you tick the "Show as expanded" option in the parent menu link.
Lastly, remove the "print theme" stuff, otherwise you end up with double menu's.
the page.tpl.php will look something like this:
<?php if ($page['navigation']): ?>
<div id="navigation"><div class="section clearfix">
<?php print render($page['navigation']); ?>
</div></div><!-- /.section, /#navigation -->
<?php endif; ?>
The stark theme out-of-the-box doesn't show submenuus in it's main menu either (2011/04).
If you however go to admin/structure/blocks, and drag the menu block to the header region in the stark theme, it has submenus.
You'll also have two menus then, the original one without submenus and the new one with submenus. You can disable the original one in admin/appearance/stark/settings.
$2c,
*-pike