Last active
July 2, 2021 16:26
-
-
Save joshuadavidnelson/dc2990036db16f9e7584239bb7002498 to your computer and use it in GitHub Desktop.
Place jQuery in the head on archive pages. You can use other conditionals in place of `is_archive()` to achieve this behavior for other conditions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use this filter to force jquery to remain in the head section of the page on archives. | |
* | |
* @see https://wordpress.org/support/topic/exclude-jquery-for-other-archive-pages/ | |
* @date 2021-07-02 | |
*/ | |
add_filter( 'stf_jquery_header', 'jdn_archive_header_scripts', 10 ); | |
function jdn_archive_header_scripts( $bool ) { | |
if ( is_archive() ) { // conditional check for the current page, is it an archive? | |
return true; | |
} | |
return $bool; | |
} | |
// Alternative, if you have a archive.php template, you could also use the built-in `__return_true` | |
// function to filter from within the setting from within the archive.php template file: | |
add_filter( 'stf_jquery_header', '__return_true' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment