Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Wordpress and Bootstrap collapsing navigation issues

Has anyone experienced a problem where the collapsible menu doesn't display the menu when it's sized for mobile devices? My Bootstrap theme refuses to display the collapsed menu neither does the finished theme developed by Zac Gordon in his blog post on Bootstrap and Wordpress. Any ideas on how to fix this?

Thanks,

Darcy

3 Answers

Eric Murphy
Eric Murphy
407 Points

I haven't watched the series yet but, I've never had an issue with that, and I have done many wordpress themes with bootstrap.

First I would check your view source and click on the javascript files to insure that they are being loaded. Seems that may be the issue.

Also when adding css and js files in a wp theme you have to add them via the functions.php

Here's a sample of something like I would use:

function wp_load_javascript_files() {

wp_register_script('site_js', get_template_directory_uri().'/js/site.js', array('jquery'), '', true );

wp_enqueue_script('site_js');

if ( is_front_page() ) {
/* wp_engueue_script or style here for use on home page */
}

Hope this makes sense

I'll have to try that out but I'm pretty sure my JS is working because I can see it when I view the source.

Eric Murphy
Eric Murphy
407 Points

Darcy,

I am not sure how you have it coded into your theme but, by wordpress coding standards you should never ever hard code any links. This means any links to js files, css files, and even to another page or external site.

Be sure to read the codex on wordpress.org for more info http://codex.wordpress.org/Function_Reference/wp_enqueue_script

When linking to another page or site you should use something like esc_url() method so a typical link to a page within your site would be something like this

<a href="<?php echo esc_url( '/about', 'http', 'display'); ?>">About Page</a>

I also forgot to mention that above the bit of code I gave you you have to add the action so it runs when the functions.php is called to do so just add above it.

add_action( 'load_javascript_files' );

More info on how to do this can be found here: http://wpcandy.com/teaches/how-to-load-scripts-in-wordpress-themes/#.UrDmxfaNWCY

Another great site for learning wordpress is http://www.wpbeginner.com/ lot of great tuts.

Best of luck,

Eric