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 trialRocket Alpaca
7,318 PointsQuestion about how <?php wp_footer(); ?> works
In the video, the navigation bar does not appear unless <?php wp_footer(); ?> is added.
My question is, where does wp_footer link to? I assumed that calls the wp_enqueue_script() from function.php, but if I comment out
wp_enqueue_script('modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false); //we don't want it to appear in footer
wp_enqueue_script('foundation_js', get_template_directory_uri() . '/js/foundation.js', array('jquery'), '', true); //foundation is DEPENDENT on jquery, we want this at footer
wp_enqueue_script('main_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true); //foundation is DEPENDENT on jquery, we want this at footer
from function.php, I can still see the navigation bar. So what exactly is wp_footer calling?
Thanks!
1 Answer
James Lees
11,225 PointsHey Rocket Alpaca,
The wp_head() and wp_footer() functions are added to the head and footer section of your theme template respectively. I suggest you open up /wp-includes/default-filters.php in your text editor, you will notice a //Actions section that includes the default actions. These default actions will be invoked when these functions are invoked. Below is an excerpt of code from default-filters.php :
add_action( 'wp_head', '_wp_render_title_tag', 1 );
add_action( 'wp_head', 'wp_enqueue_scripts', 1 );
add_action( 'wp_head', 'feed_links', 2);
You can see the some of the defaults for the wp_head() function that exist inb the WordPress core. hope this helps!
Rocket Alpaca
7,318 PointsRocket Alpaca
7,318 PointsJust looking back at the question, I think I may have got "menu" mixed up with navigation. Is the wordpress menu the only thing this function would call?