Only output function from functions.php if conditional tag is true

Move the is_tax() conditional inside the slug_scripts_masonry function. function slug_scripts_masonry() { if ( is_tax() ) { wp_enqueue_script( ‘masonry’ ); wp_enqueue_style( ‘masonry’, get_template_directory_uri().’/css/’ ); } } add_action( ‘wp_enqueue_scripts’, ‘slug_scripts_masonry’ ); Because WordPress has not yet executed the code which determines the result of is_tax() it will return false on all pages.

Masonry imagesLoaded javascript error

Followed the same article and ran into the same issue; the author (Josh Pollock) posted a followup on his blog. Essentially from WP 3.9, Masonry is there for you to use so all you need in functions.php is: add_action( ‘wp_enqueue_scripts’, ‘slug_masonry’ ); function slug_masonry( ) { wp_enqueue_script(‘masonry’); // note this is not jQuery } and … Read more