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
- WordPress generating Undefined Variable warning
- how to changes mobile menu toggle breakpoint in WordPress
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Get page permalink in contact form
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- How to display already created menus via php?
- Updating Metadata with Shortcode
- Grabbing Image name From Product Image Gallery
- Reject all malicious URL requests functions.php
- can’t load .po file in functions.php
- How to assign page id with array in page_scheduled_event
- Need help for some PHP code
- “pre_get_posts” orderby custom date field in different format?
- WP-Bakery – Add custom colors to buttons with template colors
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Can/should we delete wordpress cron jobs with no action?
- Adding an “Upgrade Subscription” button to an Elementor page
- Database entry removed on browser refresh, Ajax PHP jQuery
- WordPress User Meta value variable into Google Gauge Chart
- Add a Metabox checkbox to the Page Edit screen of wp-admin , which only certain roles can see and Makes only certain roles able to Edit said page
- Jetengine Forms – Media upload path
- Checkbox doesn’t save inside metabox
- A function to get the content of a page
- How to use Page link field with is_page()
- Using ACF Relationship field to set post type to draft or published status
- How to hide a child category and show his parent category
- Display logged in user name and lastname on page
- Adding wp users ID into a link address from a DIVI modul
- How to Add a cutsom slug to my custom author role
- Execute function only for specific user roles
- How to send a php var to jQuery Ajax call with two different file
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Change wordpress’ database data using ajax – how to get current user id?
- Woocommerce My acount page
- Woocommerce – Exclude variation attribute on specific variation
- Dynamically populate parameter in Gravity Forms using PHP
- How do I add a function to parent theme
- Can’t log in to WordPress wp-admin after adding code to functions.php
- Why would the child theme load in the Customize preview, but not on the site itself?
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Store ajax data in PHP variable
- Advanced method to control cache of enqueued style/script
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- How a HTML form can trigger a PHP function?
- Dropdown category field inside repeatable metabox
- How to change basename url for wp-admin?
- Create shortcode for metabox gallery
- Allow a user or role to view drafts and previews, but not other admin privileges?
- Retrieve alt text by referencing the img src
- How to exclude meta no index pages from wp_list_pages
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- Adding HTML Code to Replace Text in PHP
- How to Send Pingbacks for all Posts in WordPress?
- Reliable way to add nonce to HTTP Header in WordPress?
- Products listing check if meta checkbox is checked
- Show all people who commented on all posts by an author
- Trying to update Woocommerce meta values
- how to replace h1 entry title with h2 in category pages only
- Display Visual Composer shortcode if a post belongs in specific categories
- Custom function that re-writes page title breaks when the Yoast plugin is activated
- How to unset a function from a action inside a class, that is called in another class
- Create a new account on site B with data from the purchase of site A
- Why is the current page loaded in the pop-up window and not the specified one?
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- Add Featured Image to Existing Post
- How to add and subtract user meta values after post meta update
- Multiple AJAX handler functions conflict in functions.php