Try using is_post_type_archive()
and is_singular()
:
// ...
if ( is_post_type_archive( 'my-post-type' ) || is_singular( 'my-post-type' ) ) {
// your enqueue code goes here
}
// ...
These functions will check to see if you’re on, respectively, an archive page for the post type my-post-type
or a single my-post-type
post. (Change the my-post-type
to what you’ve named your custom post type when you registered it, of course.)
Related Posts:
- Enqueue less file not working in child theme?
- How to enqueue CSS and JS only on specific template?
- linking stylesheets and scripts with functions.php
- Enqueueing a code block from an options framework
- Execute only on a certain page
- Check if current page is wp-admin
- Adding tawk.to code just before body tag on functions.php file
- Deregistering a script in WordPress seems impossible
- Enqueue scripts not working with if is page conditional tag in functions.php
- Need help enqueueing webfonts
- responsive.css in the WordPress should be prioritized
- How to change menu labels
- jQuery code not working when included in functions.php
- Is the wp_enqueue method efficient?
- get_template_directory adding FTP root folders in urls
- Enqueing External JS on the remote server JS
- child parent styles enqueue order
- How to make a cookie be on the whole site instead of being on a specific page/
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- How can i create a function tag in my plugin
- Enqueue assets from multiple directories using add_action/do_action
- How to change order inside foreach using wp_enqueue_script?
- Call a single function on two different methods with hooks
- Enqueue sripts and styles only if function is called
- Load script and styles using an array of resources
- Chosen Select jquery Not Working in Plugin
- How can I print out a single stylesheet or javascript link?
- Adding Gravity Form With if(is_page) Is Not Working
- wp_enqueue_style conflict when using in different action hooks
- Load slideshow.css file only if Slideshow is checked / on
- Warning: filemtime(): stat failed for wp_
- functions.php doesn’t load all custom theme assets
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Modify previous and next text from pagination links
- Shortcode putting html such as
- Calling a method from functions.php on a click of a button
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- “wp_enqueue_style();” don’t load new edited style
- How do I create comment-reply-button using element not
- Enqueue script o style only if a template part is loaded
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Output 2 items within the Loop
- How to check If Oembed is empty or not
- Making Quote Plugin more efficient
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Fatal error: Uncaught Error: Call to undefined function test()
- Return a numerical function value in Customizer controls
- How can I get the values of my WordPress $wpdb query in Jquery?
- Css loads very slow [closed]
- Show when user is online/offline in real time on user_profile.php
- theme_root returning a truncated URI
- Call to undefined function get_userdata() in plugin
- Echo string and function?
- how to test for all children (including multilevel grand-childern) of page
- Dilemma of Populating all the categories in a drop down list
- Add item to top of menu using a filter in functions.php
- Adding wrapper elements in the_date() like in the_title()?
- Notify users only on post publish
- Plugin Generate Unexpected output during activation
- Limit Taxonomy Output in Conditional Statement
- wp_redirect only works on main site and not on other sites
- require_once() if a product in woocommerce contains a tag [closed]
- How to get current post category details inside “loop”?
- Only load certain artists on this page
- Conditional for Post Format
- Get the alt text of the image in a array
- Make table disappear when fields are left blank?
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- Woocommerce order status payment
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Unzip file in functions.php, and add it to cron
- Add Block Before Entry Title Using PHP
- Display logged in user name and lastname on page
- How to Add a cutsom slug to my custom author role
- Dynamically populate parameter in Gravity Forms using PHP
- Store ajax data in PHP variable
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- How to output the taxonomies that are assigned to each custom post?
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How to escape echo for input tag?
- Including user data in “new user notification email”
- Display current user metadata on WordPress page
- Reload page with a different shortcode when a user selects from a dropdown
- Refresh page after login with litespeed cache
- Woocommerce Add custom “Add to cart button” in single page with tags
- remove_action() not working in page template – Genesis
- What is wrong in this code?
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Show custom default avatar instead of gravatar
- wp add inline style in loop
- WordPress 2014 Theme – Featured Content with multiple tags?
- ajax form function error
- Display custom meta box in my template file
- How to display the date under the post title?
- Simple Probléme in wordpress
- Add multiple HTML attributes to an Elementor button
- /page/2/ redirect to 404