Trying to load JavaScript only on pages within a PODS category/ custom post type

I’d like to load CSS but only on certain pages.

This code normally works great but I cant figure out the ‘Conditional Tag’ what will only load these pages.

This is the function I place in my functions.php file:

//Below loads JS ONLY for the main directory pages
function directory_scripts () {
        if ( *** NOT SURE *** ):
            'addevent js',
            get_stylesheet_directory_uri() . '/js/addevent.js',

// add_action( 'wp_enqueue_scripts', 'directory_scripts' );

What I do normally is look in the <body> tag to see what I can reference but it just doesn’t want to work…

Here is my <body> info:

<body class="conference_2018-template-default single single-conference_2018 postid-3025 wp-custom-logo oceanwp-theme fullscreen-mobile no-header-border default-breakpoint has-sidebar content-right-sidebar has-topbar page-header-disabled has-breadcrumbs elementor-default ">

Is it because I am using PODS Custom Post WordPress Framework?

My URL structure is like this:

http:// / directory / page-here

^ I am trying to place the JS in the above ‘page-here’ pages…

Thanks for all help

New User Asked on September 19, 2018 in Customizations.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service. | Learn how to add/edit code.