Try adding classes, instead of restricting the CSS to certain pages.
You should be looking for classes that will allow you to apply your styles to those pages only. Usually the CSS for the entire site will be loaded at once and kept in the cache. So don’t try to load the styles only on certain pages, instead provide styles that override existing styles only on the pages you want to modify.
Check the body_class
function, it produces the classes you need may on the <body>
tag already.
And if that is not enough, try changing the template to output the category as a class name.
Also, you should not just inject a stylesheet into the head, you should use wp_enqueue_script
to add new styles, but you shouldn’t really need to do that either.
Related Posts:
- WooCommerce change number of columns in the frontpage
- WordPress custom styles in menu page
- Overriding WooCommerce CSS? [closed]
- Old Site displays on Mobile View, not New Site
- Unable to remove space between header and slider section in wordpress website
- WordPress problematic caching
- why this media query is not working / not loading when I put it in child theme?
- Rendering css to screen and debug problem
- How to use Japanese characters for a single page
- How to link theme fonts directory in WordPress CSS?
- How to get DEFER or ASYNC attribute to appear when I add a stylesheet with wp_enqueue_style from a plugin? [duplicate]
- show count is out of the anchor tag in wp_list_categories
- Which filter affects the ‘entry-title’ post class
- No responsive design is displayed
- Certain aspects of site suddenly not working in Chrome and Firefox
- How does W3 Total Cache Load Images In Stylesheet via CDN? [closed]
- images within style sheet
- How do I make header.php use different css for different pages?
- IE and WordPress
- How to change header dimensions in WordPress?
- Trying to figure out why my child theme is trying to access a file that doesn’t exist
- jQuery UI styles conflicting with TinyMCE dialog
- How to display custom style based on theme option select box
- Edit css for search results page
- How can I use one stylesheet for multiple sub-sites on my multi-site network?
- How to disable the hover effect in WordPress and Elementor?
- Archive pages have smaller font then the rest of my website [closed]
- Adding CSS to custom post type admin page causes error
- Code working just in specific time period
- What makes WP so SEO friendly?
- what could cause get_stylesheet_directory_uri() to fail?
- Load CSS in footer, like your can with JS?
- Images loaded as background-image are shown but s aren’t
- Child theme CSS not applying to element
- Delete a white space using css
- How to use my menu PHP code as sidebar?
- Redirect to another page using contact form 7? [closed]
- Correct Way To Make Changes To A WordPress Theme
- How to stop my themes CSS changing the WordPress interface/?
- Title has word broken when viewed in mobile [closed]
- Twenty Fifteen : Wider right column for the content
- How to change the full capitals font title of my WordPress Blog?
- How to add inline css code with background image in page html code?
- Moving button on Online Consulting theme
- How to Style Primary Menu with Active Class
- Child theme stylesheet not always overriding “index”
- Edit External CSS
- Set 3 iframes in a row
- Move Sidebar from Above Content To Below When Responsive [closed]
- Stop Plugin from Getting Styles from Other Plugin
- How do I apply/target CSS to a specific user role or roles?
- Style WP_Debug?
- How to add a custom CSS class to ALL links
- Why is this jquery / java script code not working in mobile / in devices?
- CSS not applying in admin
- Seperate functions.php for part of site
- Change background color of subpages
- loading a custom stylesheet in a function
- Internet Explorer ignore my css
- wordpress css file
- css file status 403
- Load jQuery only on home page
- How to change H1 color only for pages [closed]
- Alternate stylesheet only works with absolute address for link?
- Unable to align my sidebar to the contents section instead of comments
- how to hide submenus for the not active pages
- How do I use add_action on custom widget?
- Why is the CSS horizontal alignment for divs inside div container not displayed in my WP Theme?
- Why Do I get “wp_remote-get: could not handle for fopen()”?
- How to apply next/previous classes to LIs for pagination links?
- How can I get the search form to be selected automatically?
- How to edit the default icon of Add Media button?
- Override plugin styles via my custom theme
- How to add CSS via custom plugin?
- Implementing a simple slider in code?
- Understanding how the class family `inner-container` works
- How to deal with logo color on dark mode?
- Google yolo one tab signup plugin avilable in wordpress? [closed]
- CSS – Initial HTML Margin Issue On WordPress Site
- Cannot set property ‘className’ of null at setThemeFromCookie
- How can I remove the ::after CSS selector which is automaticaly appended to the_content()?
- Plugin Theme CSS [closed]
- Make CSS Changes To Only Affect Mobile Browser [closed]
- Full list of registered scripts or styles, but from an admin options page
- Hover colour spreading out beyond submit button
- How to fix this error? [closed]
- Disable File Editing function
- Background image reversed on pages after home page [closed]
- Header background image just stopped working
- Overwrite a plugin’s CSS?
- Keeping CSS model open after form submission
- Sidebar button click redirect when user is not logged in instead displays it
- Some Text of website page on Iphone Safari become invisible
- Adding Custom css file
- How to get an unique identifier for a page/post/category/tag etc.?
- Page layout is broken when viewing search results.
- Combining several CSS files into one for optimization
- Child Theme CSS not showing at all
- Advanced: understanding wp_add_inline_style function
- How to add a dvi tag to a shortcode then change a generated text using jQuery