In order to optimize my site for a bit more loading speed, I wanted to enqueue a couple of scripts only to the archives for default post type. A rough example is given below.
function my_theme_script_enqueues() {
if (!is_admin()) {
if ( is_archive()) {
wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js', 'jquery');
wp_enqueue_script('isotope');
}
}
}
add_action (blah..blah..blah..blah)
I assumed something like (is_archive('post')) would work, but it still loads on cpt-archive and tag archives and such ( does not load on pages though).
I cant use (is_archive())
as it again loads it to every other archive types eg. cpt-archives, tags etc which is pointless to me.
If I use if (!is_post_type_archive('cpt')) {...}
then it obviously goes wild and loads it everywhere else, not scalable.
I know how to use if( is_post_type_archive('post')) {...}
, but it is not giving me any result, which it should i guess as 'post' is a post-type right? When I search for a solution here I get mostly threads talking about custom post type archive. Please let me know what my alternative is?