Drop Down not working
Hello,
I am currently attempting to implement this resource for a WordPress theme I am working on. I am developing it on my local computer.
For some reason I can't get the drop down to work. I followed the instructions and put the necessary code into my functions.php file and the header.php and I put the nav walker into the root of the theme folder.
Not sure why it's not working.
Am I missing something?
Bootstrap dropdowns require a click to open them so that they are mobile compatable. I now it seems silly to ask but did you try clicking to open? I've had clients contact me saying the same thing because they had only hovered to check - never realised mobile dropdowns required that click :p
lol, Yeah. I did click the carat and nothing happened. Not quite sure what the issue is. I've tried to trouble shoot it but no success. Am I supposed to change anything when adding the code to my theme? Should I be changing any of the CSS in the Style sheet? Thanks.
What I did to date was place the nav walker file in the root of my Theme, placed the require code in the functions.php, registered the menu in functions.php and added the code to the header.php.
Does the rest of the menu work/render correctly? I had a similar problem once, and it was because I was not using the container in the Walker, and I was missing one of the classes needed.
What your doing should be enough to get it working so long as your also including bootstrap CSS and js (I assume you are).
Have you looked at the markup on the page to see if it is including the drop down and just not displaying it? You can use firebug for FF or the inspector on chrome to see if it's there on the page.
Also just wondering but the code you have in header.php doesn't set the depth to 0 does it? Should have asked that first lol
I'm not at a computer just now so i can't test things out try recreate what your seeing but I'll be at my laptop in about an hour so if you're still having problems I'll be able to help out better then.
Yeah, the menu works but the drop down doesn't. NOTE: When I resize the viewport in my browser to what would be a mobile size the hamburger menu works but is a little delayed. Not sure if that is how it's supposed to be.
What do you mean not using the container in the walker? and what class was needed? I might have the same problem? Thanks.
The depth is set to 2. I literally just copied the code over verbatim. Yes, I have all the bootstrap files uploaded properly as far as I can tell. All the other bootstrap features seem to work fine. Let me check the inspector for the other item you mentioned. Thanks
Have you included your Bootstrap javascript properly in your functions.php file? Please check previously closed issues related to your problem. If you still have problems we'll look at your code files together.
I wanted to use the Bootstrap navbar-right div so I removed the 'container' and 'container_class' from the wp_nav_menu array. This allowed me to use a WordPress menu for the main nav, and have a login/loggedin button right aligned. But it sounds like that's not your issue.
Another thought, are you using a customized Bootstrap? If so, did you include 'navbar' and 'dropdowns' in your package?
I downloaded the full bootstrap package.
This is the code in my functions file. I believe it's correct. Everything else on the site works.
function theme_styles() { wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css'); wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css'); }
add_action('wp_enqueue_scripts', 'theme_styles');
function theme_js() { global $wp_scripts;
wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js', '', '', false);
wp_register_script( 'respond_js', 'https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js', '', '', false);
$wp_scripts->add_data('html5_shiv', 'conditional', 'lt IE 9');
$wp_scripts->add_data('respond_js', 'conditional', 'lt IE 9');
wp_enqueue_script('bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
wp_enqueue_script('theme_js', get_template_directory_uri() . '/js/theme.js', array('jquery', 'bootstrap_js'), '', true );
}
add_action('wp_enqueue_scripts', 'theme_js');
add_theme_support('menus'); add_theme_support('post-thumbnails');
function register_theme_menus() { // Register Custom Navigation Walker require_once('wp_bootstrap_navwalker.php');
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'bootstrap-to-wp' ),
) ); }
add_action('init', 'register_theme_menus');
It doesn't sound like the problem is in your functions file, to me, since the navwalker loads. I think its in either your nav file or in the js/css (which look like they should be loading okay)
Interesting. Is there any css I should be including that is unique for this?
Okay guys, my notification ringtone is driving me nuts. Please take a moment to relax. Also:
It seems that my previous comment offering to help has been overlooked, not nice.
@citidm Your function file is not well written: ~~a semicolon is missing~~, 'add_theme_support(menus)' is not a valid function, ... I am preparing a gist for you that should solve your problem, stand by. Also as a beginner I urge you to take time to read the WordPress Codex on Theme Development.
and maybe the GitHub docs about how to include code in comments ;)
Thanks @cristovaov Sorry about that. I appreciate your help.
No worries - I hope I didn't come to harsh, I mean no disrespect.
Here's the gist. I provided a small comment on what to do at the top of each file and used the default markup for the menu from the instructions page. https://gist.github.com/cristovaov/ab0ae1a1c8ef250316f4
Let me know if it worked or if more help is needed~
Thanks @cristovaov , for some reason it's still not working. SMH, I'm sure I'm missing something and it's probably so simple and when I find it I will be like DUH.
can you upload your whole theme to a new repository or make a gist with your functions.php file and header.php file to have a proper look?
@cristovaov after hours of trying to figure it out I finely had that DUH moment. Plugin conflict. I previously installed this plugin http://wordpress.org/plugins/bootstrap-shortcodes/ which has great reviews. I just deleted it and the drop down finally worked. I also tried to upload a new repository by using the mac.github client but since I've never used it before I figured I'd learn it another day. Thanks for your help and patience.