Write this in your theme’s functions.php file
function category_enqueue_script() {
$cat_education_id = 'xx'; // category id for "education"
$cat_dog_id = 'yy'; // category id for "dog"
if ( is_category() && ( is_category( $cat_education_id ) || is_category( $cat_dog_id ) ) ) {
wp_enqueue_script( 'my-js', 'filename.js', false );
}
}
add_action( 'wp_enqueue_scripts', 'category_enqueue_script' );
Related Posts:
- Get term by slug in Gutenberg
- How to add custom script to the particular Product Category page
- wp_dropdown_categories() scripts working erratically on sidebar
- REST API: Display Category names in JSON?
- wp_dropdown_categories not showing option as selected
- javascripts files not linking to my category slugs?
- ADD DYNAMIC attribute for category to accordion
- How to check a category checkbox using JavaScript
- Can’t filter categories using isotope
- Multisite – Protect categories from deletion?
- Where/how are categories stored?
- Get top parent category
- wp_update_nav_menu_item() to insert categories
- Redirecting specific category posts to subdomain
- How can I prevent users from creating new categories?
- Get child categories when clicking on parent category
- Custom color for each category name
- Block multiple categories from Blog
- Show posts of one category only with Custom Taxonomy on single.php
- Wrap a chosen category name with div
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Category tree is flattened inside admin upon saving
- Get woocommerce catogry
- Get last post date yesterday from each categories not work & double result post
- How do I add a function on a specific post category?
- Open subcategories in submenu on click in primary menu
- How to add Categories to the top menu of the website?
- Multiple categories PROBLEM and Duplicating main categories
- force category base – archive pages work WITH & WITHOUT category base slug in url?
- Retrieve Image from Media Library by it’s category
- Getting URL of archive (category) page
- Strip a word from wp_list_categories
- Exclude category from fucntion
- Get Unique Categories – Group By?
- Filter Categories in meta box for CPTs
- Site search needs to find posts for category topic AND Tag or keyword thats not in the post
- Get category url in loop
- Previous/next post links displaying wrong category than is desired
- List only child categories within posts
- Admin comments and user restrictions
- category url structure
- Order by category titles
- How to conditionally hide author name on Single.php if category is “news”, otherwise if category is something else display author name?
- How to let users choose posts order in categories?
- WordPress category
- Different Output for “Every Other” Foreach Statement?
- And/Or Category Query
- Show subcategories on a parent category page
- How do I add Category Body Classes to Admin?
- not all categories being displayed
- Category archive is displaying all posts rather than the specific category
- Use the category name instead of category slug in permalinks
- How can I display the number of post associated to a category in Twig/Timber WordPress? [closed]
- How to display the parent category if only the child category has been chosen
- Multiple Category Search with and operator in WordPress
- Display list categories from CTP
- Different CSS class by category
- Remove any product that is featured from regular display loop [WooCommerce]
- Latest updated categories list query, exclude one from displaying
- How the posts and categories connected each other in wp 4.1.1?
- Getting parent category hierarchy as objects from category template
- Ordering categories by slug vs. name
- Using in ‘category_name’ in ‘$query->set();’?
- Setting selected term_id with wp_dropdown_categories?
- how can i hide category?
- Homepage custom recent news
- post_class remove tag- or category- from slug
- creating categories programmatically
- Pagination for a category
- Assign a list of categories with a parent category
- Custom post type archive category page results in 404
- WP-CLI Add category as menu item main-menu
- Can’t get selected value from wp_dropdown_categories or get_categories
- How to get specific (grand parent) category of current post?
- Blog page with posts from specific categories
- Exclude a category and post_type from wp_query
- How to remove parent category from child category url using wordpress rewrite rule?
- loop in single.php of the same category
- How to assign Categories and tags inside the TinyMCE Editor for each Image?
- outputting taxonomy hierarchy
- Make category archives page in menu non-clickable
- Exclude specific Categories from displaying on post but not in lists
- Display Some text in some specific category not all category
- Why use hierarchical taxonomies instead of many custom taxonomies?
- Breadcrumbs and Categories
- Search by tag, category and author without plugin
- How to show posts only for the last subcategory?
- Hide category links if there is nothing in the categories – Main Navigation submenu item
- Create monthly archive for parent category
- Different styles for categories – need to edit a plugin
- Unable to get all tags from specific categories
- Hide all posts by an author
- How to display post title and link within wp_list_categories()
- Right way for setting categories
- Rewrite category list as an if / else statement
- Displaying just one post from each category on archive page
- Exclude categories from homepage but not from sidebar
- Exclude Specific Categories?
- How to change category id on get_posts array
- CPT Custom post type Tags & Categories not showing for ‘Editor’ user in editor