I agreed with @PatJ — you should check if get_queried_object()
returns an object or not.
But you could simplify your code by simply using is_category()
and in_category()
which are conditional tags in WordPress:
if ( is_category( 3 ) || in_category( 'arta' ) ) {
wp_enqueue_style( 'twentytwenty-style-2', get_stylesheet_directory_uri() . '/style-arta.css', array(), $theme_version );
}
Related Posts:
- “wp_enqueue_style();” don’t load new edited style
- Understanding child theme functions.php
- wp_enqueue_style with style.php and WordPress functions
- Is it possible to use the featured image of a page as a css background without inlining?
- Plugin CSS not enqueing
- Parent theme CSS overriding child CSS rules
- Whats the proper way to use a php stylesheet in a wordpress theme? [duplicate]
- responsive.css in the WordPress should be prioritized
- Odd / Even posts add class minus first post
- Parse error: syntax error, unexpected ‘}’ [closed]
- Why would the child theme load in the Customize preview, but not on the site itself?
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- Site title not showing. Please help me
- Modify arguments for parent theme’s `wp_register_style` via child theme
- wp add inline style in loop
- How to NOT override inline css rules
- Query Concatenation
- WP_Query not returning results
- Styling best practices for single pages/templates
- taxonomy pages returning “NULL” when running default WordPress function ‘get_queried_object()’
- how to remove metadata from the posts of my blog?
- How to find error in my code when the error message is pointing to WP core file?
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Storing Array from returned database query and using the array in a new query
- How to style options page in dashboard?
- Theme Options Page – User Updates Logo
- get_term_link() returns correct – But illogical error-messages disturb
- How to use my style.css file outside of wordpress subdomain?
- Parse error syntax error unexpected t_string [closed]
- Dynamic Stylesheet loads but doesn’t finish
- How to add date to navigation bar
- mysql query from wordpress page using custom table
- Selectbox in admin panel function linking to CSS
- WordPress 3.2 query_posts and pagination, permalinks issue
- Can I install/embed WordPress on a ‘single page’?
- only show container with next/prev links if they exist?
- Using if/else statements with output from theme options
- Is there CSS to expand the gallery limit on Index Pages?
- PHP Warning: Attempt to read property “term_id” on bool
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- How to design a table based on css values set from admin/dashboard
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- Mute Debug Messages from Plugins
- Set WP_query ‘order’ option by another tables value
- WordPress Script stops suddenly
- A non-numeric value encountered in /wp-includes/functions.php on line 68
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Error on wp_default_style After upgrade to php 7
- Increase offset while looping
- Incorrect MIME type for assets with Valet
- How to display pictures from database?
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- How to add condition in wordpress loop? [closed]
- Customize position of social icons in upme plugin [closed]
- How to pre populate a form field with a link of a current user’s author profile?
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Best way to schedule daily change in CSS parameter
- Css loads very slow [closed]
- Gravity form built in Captcha
- How does wp_enqueue_scripts work?
- Different post styles depending on category
- How create a Shortcode with hover and complex options
- WordPress Multiple Navigation bars
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Getting error when using wp_insert_post()
- two columns of posts on homepage, one of them “favorites”
- Error: options page not found
- Need help enqueueing webfonts
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- register_taxonomy() take much queries
- custom css for admin only
- Font Awesome changing default WordPress Font
- Headers already sent in Pluggable.php / homepage and wp-login error
- How do I add a custom css to all posts without affecting homepage css? [closed]
- WordPress SQL injection
- How to change menu labels
- Custom Background by Page IDs
- proper way to add css using functions.php?
- WordPress style.css not updating, only after theme reload
- “Undefined index” error when saving empty array with checkboxes
- Adding logo to WordPress header
- Thumbnails appear to be zoomed
- Use PHP in stylesheet to specify a background image based on Category ID
- Automatically set all tags to have a height of 0 if there is no content inside the tag [closed]
- height should be set to auto to avoid pixelation in the post thumbnail function
- Change CSS based on is_user_logged_in
- Is the wp_enqueue method efficient?
- RTL Stylesheet Confusion with WordPress
- Correct way to enqueue page specific CSS file
- Wrapping a Sidebar within
- unable to use ‘new WP_Query’ in AJAX call
- Add Codepen animation as Preloader to WordPress
- WordPress wp_add_inline_style unable to give hex colors?
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- Reduce size of responsive title