Why aren't the links in my sidenav working? - php

I've been working on a wordpress theme using the materializecss framework. I can't get the links in the sidenav to work, the sidenav will slide out no problem but the links don't work. Below is a link to the c9.io box.
https://loftymaterial-chubbymaus.c9users.io/
here is the code for the sidenav
<?php wp_nav_menu( array(
'theme_location' => 'mobilemenu',
'menu_class' => 'side-nav',
'menu_id' => 'nav-mobile'
));?>
<i class="material-icons">menu</i>
and this is how the mobilemenu is registered
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'loftymaterial' ),
'mobilemenu' => __( 'Mobile Menu', 'loftymaterial' )
) );
any thoughts you have are greatly appreciated. Thanks

Issue is because of the #sidenav-overlay element, it is positioned on top of the side menu, use the below CSS, make sure to put it in a CSS file which loads after the materialize.css file
#sidenav-overlay{
z-index: 996;
}

Related

wordpress custom menu with page thumbnail

I am trying to get a menu with few links, and show their/link/page featured image. following is my code for functions.php.
function register_my_menus() {
register_nav_menus(
array(
'main-menu' => __( 'Main Menu' ),
'useful-links' => __( 'Userful Links' )
)
);
}
add_action( 'init', 'register_my_menus' );
and this is where i am calling it in the page.
<?php wp_nav_menu( array( 'theme_location' => 'useful-links', 'sort_column' => 'menu_order', 'container_class' => 'useful-links', 'menu'=>'Posts Menu' ) ); ?>
i know something is missing but kindly advice. my page look and feel allow 6 links and their images.
thanks
This should be in your functions.php to register the menu within WordPress.
if (!function_exists('wp_basicTemplateSetup')) {
function wp_basicTemplateSetup() {
// Register the Main Menus into WordPress
register_nav_menus(array(
'primary' => __('Main Menu', 'theme-name'),
));
}
}
add_action('after_setup_theme', 'wp_basicTemplateSetup');
In your theme, where the menu is sitting you need to tell the menu function, which menu to look for. So..:
// Variable that tells WordPress which menu to use, look at "Theme Location"
// Put this variable either at the top of your theme, of right *before* the function wp_nav_menu
$mainmenu = array(
'theme_location' => 'primary',
'container' => false,
'menu_class' => 'some-menu-css-class',
'depth' => 2
);
// The WordPress menu function
<?php wp_nav_menu($mainmenu); ?>
These 3 components are necessary to get your WordPress menu working.

Wordpress menus

i m having a problem with menus.
I had a template that wasnt originaly for WP.
so i integrated it.
when i started the site there was only one menu which works great.
i added <?php wp_nav_menu('primary'); ?> and its all ok
Now i need to add another one (custom links in the header section)
sooo i used this method
register_nav_menus( array(
'header' => 'Header menu',
'footer' => 'Footer menu'
) );
and recieved new locations for menus.
for the second menu i added
<?php wp_nav_menu( array( 'theme_location' => 'header', 'menu_class' => 'nav-menu', 'fallback_cb' => false ) ); ?>
now the problem:
there is a primary menu (it has few items)
and the custom menu ( its currently empty)
when i add new page to custom menu its being shown in both primary and custom menus.
if i delete all the items from custom menu, primary menu items are back in place...
what is the problem?
Thank you.
If I understand correctly, it looks like you are pointing to the wrong registered menu in the wp_nav_menu(). Specifically in the theme_location.
When you are building the "second menu" which is the "footer", theme_location should be footer since that is the name you gave it in the register_nav_menus().
<?php wp_nav_menu(
array( 'theme_location' => 'footer', // Change 'header' to 'footer'
'menu_class' => 'nav-menu',
'fallback_cb' => false )
);
?>

Add footer menu to theme support only one header menu in wordpress

i Download and activate theme but i find that there is no way with setting to add links to footer menu because its support only one header menu
i download the Genesis Simple Menus from here https://wordpress.org/plugins/genesis-simple-menus/ and add this code in the functions.php file :-
// display the Footer Navigation
add_action('genesis_before_footer', 'wdm_add_footer_menu');
function wdm_add_footer_menu()
{
wp_nav_menu(array(
'sort_column' => 'menu_order',
'container_id' => 'footer' ,
'menu_class' => 'menu-tertiary',
'theme_location' => 'footer',
'depth' => 1,
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'
) );
}
but nothing happened is that anyway to make this theme have footer location menu???
Add register_nav_menu('footer', 'Footer Menu'); in your functions.php
See this for details: https://codex.wordpress.org/Function_Reference/register_nav_menu
Follow the below link,hope it helps your cause,
http://premium.wpmudev.org/blog/add-menus-to-wordpress/

How can I programatically change menu in Wordpress?

I've created one menu in Norwegian menu_no and one in English menu_en.
I can see that my theme supports only one menu, but I'm not planning on using more that one menu at a time. So when user selects English language, how can I change the active menu?
I've not found anything on Google and I can't find the right function in nav-menu.php.
UPDATE
I found quite a simple solution for my problem. I just had to think a bit differently. In my functions.phpI added this code:
add_action('init', 'register_menus');
function register_menus(){
register_nav_menus( array(
'menu_no' => 'Norwegian menu',
'menu_en' => 'English menu',
) );
}
and in my header.php file I use this code:
global $lang;
$args = array(
'theme_location' => 'menu_'.$lang,
'container' => false
);
<?php wp_nav_menu($args); ?>
Voila. I'll post it as answer later - if not anyone else comes up with a better idea.
Here is How You Can Do That.
Past this code to function.php file
// Register Navigation Menus
function custom_navigation_menus() {
$locations = array(
'first_menu' => __( 'Menu for English language', 'text_domain' ),
'second_menu' => __( 'Menu for Other Language', 'text_domain' ),
);
register_nav_menus( $locations );
}
// Hook into the 'init' action
add_action( 'init', 'custom_navigation_menus' );
You can customize the above code.
Now use wp_nav_menu function to display anywhere you want like this
<?php
wp_nav_menu( array(
'menu' => 'primary',
'theme_location' => 'first_menu',
);
?>
<?php
wp_nav_menu( array(
'menu' => 'secondary',
'theme_location' => 'second_menu',
);
?>
You can display each menu in different places. Now you to Option in you menu Primary and Secondary

WP Footer Menu Not working?

I have been working on a site to change from HTML To Wordpress CMS...so got completed everything...Now stuck in one problem..and that is that I have declared the Main Navigation and Footer Navigation correctly (according to me) in functions.php file as :
/* Register Nav Main Menu */
register_nav_menus (array('main-nav' => 'Main Navigation'));
register_nav_menus (array('footer-nav' => 'Footer Navigation'));
while I am calling the both menus in correct way as for main-nav I am calling it in header.php as :
wp_nav_menu( array( 'menu' => 'main-nav' ));
while calling the footer-nav as following in footer.php as :
wp_nav_menu( array( 'menu' => 'footer-nav' ));
but in both places only main-nav is shown...so what did I do wrong please?..Need a hand to fix it...!
Waiting for your replies..!
Here is live link to the site as : http://www.huntedhunter.com/minaterra/
try changing:
wp_nav_menu( array( 'menu' => 'footer-nav' ));
to
wp_nav_menu( array( 'theme_location' => 'footer-nav' ));

Categories