I'm working on a custom theme and for a specific reason am not using the get_header() function.
I enqueue scripts and styles with wp_enqueue_script and wp_enqueue_style, repectively and can get it to work if I call the get_header() function. No problem there.
The thing is that I'm customizing my header and get_header() adds code I don't need. How can I get the enqueued scripts and styles to show up somewhere that's not in the header or footer that appear with get_header() or get_footer()?
For example:
<head>
<title>This is the title</title>
<!-- scripts
================ -->
SHOW ENQUEUED SCRIPTS HERE
<!-- styles
================ -->
SHOW ENQUEUED STYLES HERE
</head>
I was able to figure it out, so I'll post the answer because I didn't see anything relevant in Google.
There's a hook called
wp_print_footer_scripts
If you add the following line of code, you can get your scripts and styles to show up where you wrote the snippet:
If you want to split the styles from the scripts, you can use the two functions that are used in the
_wp_footer_scripts
callback function:So, the example code shown in the question would end up like this:
or just using the hook: