Everything in WP has an ID. As long as your theme is using body_class
you probably already have built-in classes that will cover your scenario.
For example:
- Pages will include a
page-id-##
class, where ## is the id specific to that particular page. - The homepage will include a
home
class and if it’s your main blog archive also ablog
class. - Posts and custom post types will include a
postid-##
class, where ## is the id specific to that particular post/CPT. - Categories will include a
category-##
class, where ## is the id specific to that particular post.
So, you should be able to use built-in functionality to identify content. All your theme has to do is, in header.php
, use body_class
like this:
<body <?php body_class(); ?>>
Related Posts:
- What’s the difference between SCSS and Sass?
- How am I supposed to use index.html?
- Column order manipulation using col-lg-push and col-lg-pull in Twitter Bootstrap 3
- What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap?
- Adding border to SVG image
- What does !important mean in CSS?
- Set line spacing
- Insert a group block inside a list item
- Remove / Disable default custom.css?ver=1.0.0
- How enqueue CSS out of theme folder?
- Styling not refreshing for old visitors on WordPress
- WordPress site suddenly not showing some DOM elements but mobile is fine
- Remove the main title, but only from the main page
- aos properties ‘invalid’ and not recognised when included as a css class [closed]
- How to include Elementor CSS in custom php file [closed]
- Bullet points not showing in wordpress
- Layout totally broken
- ACF Extended : Disable styles in front [closed]
- Full Site Editing Non-editble global styles?
- Block content rendered with inline CSS. How do I reuse it in a headless setup?
- How to add CSS to WordPress
- How to add arbitrary custom CSS to a WordPress Block Theme using Site Editor?
- Wrap post titles containing slashes on narrow viewports
- How to remove class=”wp-block-heading” from Heading tags?
- Gutenberg: where to find style settings
- Import css file from node_modules using @wordpress/scripts
- How to avoid problems caused by new block-library default CSS rules (wp 6.1.1)
- Website is not showing updated CSS
- A website built using wordpress, but the articles on the sidebar of this webpage cannot be displayed
- Custom block style not working in the editor
- Grid problem on privew mode
- Disabling double vertical scrollbar and horizontal scrolling?
- Editing size of h3 tag in wordpress on a one-off basis
- Content doesn’t fit on large size desktops like 2560×1440
- How to hide button with CSS class?
- Customize margin between paragraphs using the Gutenberg Style editor
- What is unsafe about this CSS?
- How to remove automatically added custom style tag?
- IOS Ventura Safari 16.3 position fixed elements goes above scroll bar
- Busting Browser Cache when updating stylesheet of WordPress website
- adjust posts size into columns wordpress
- Elementor Contact Form Submit button has empty class
- How can I make one button a different color from the other buttons on my site?
- How can I highlight the active page using paginate_links()?
- How to solve WordPress accordion problem on Iphone?
- How do I change the CSS for all Page Title sections across an Elementor website?
- add custom image to bottom of wordpress default login screen
- Style priority in theme.json
- Style.css and .js files doesn’t load at first – load only after forced reload
- My backround image in css is not showing
- How to add a class to a core block in both admin editor and frontend?
- changing the banner color of “[product] has been added to your cart.”
- Twenty Twenty Four Theme – Image and text same height?
- How to force Gutenberg to follow all custom CSS styling in preview?
- Hide Span Class from Certain Page
- Hyperlink Underline using Border-Bottom Showing Up Under Site Logo Image
- Get Sub-Menu Dropdown to Show Over Page Content Avada
- How to Inline Critical CSS Correctly
- Header menu permanently expanded in header responsive theme
- How do i configure vscode live preview for simple wordpress style.css edits?
- Content and design customizer does not match publication WordPress
- Styles not showing up in WordPress site
- Disable WP-Elements Class Creation (Gutenberg)
- How to optimise Text to HTML ratio for SEO by separating the HTML into multiple files?
- Check if a new WordPress post is successfully published with jQuery
- hide specific css and js files in specific page wordpress with id or without?
- Separate typography controls for titles and meta in a custom block?
- How to remove default flex child margin?
- Critical CSS won’t load
- Enqueue Stylesheet on the front end and in the block editor Conditionally
- Turn off/modify specific pre-rendered Gutenberg editor CSS styles
- Sass @use and the style.css file header
- Not sure why inspecting element on windows is different that what im seeing on mobile?
- wordpress generated inline css missing after migration
- unable to find the document body in user-edit admin using javascript or CSS
- difference between code for admin, user facing (css, js)
- Identify and style the paragraph beginning w/o a class: based on a combination of common characters (CSS, JS)
- QUERY LOOP Custom CSS: Overlay feature image on Posts Grid- UPDATED
- How do I remove/hide embed excerpts from posts
- Injecting CSS into Iframe
- In Oxygen Bulder, is there any way to set global page width to 100% of the browser window?
- Style.css file gets restored to default version
- Wrong mime types served
- Why is TinyMCE 4.x not using updated CSS even with forced reload? [closed]
- Block style variations not enqueued for blocks inside HTML code dynamically rendered via JS
- when I am logged in my page seems to be proper, but when I am just visiting the page in incognito, some css are not applied & page looks weired
- Block editor: can’t change format of inline code blocks
- I’m tryng to set up my social wall on WordPress but the CSS somehow gets out of control [closed]
- why I could not use data in WordPress additional css part
- Load RTL CSS using block.json for block development
- Gutenberg inline style messing up the navigation when I add a list to a page
- WordPress login/register custom CSS not working?
- Problem with spacing sizes in theme.json
- Why does the “visual editor” add useless html-comments and how can I get rid of them?
- WordPress custom css/js version not loading correct
- How to overwrite a thrid party block’s css in a child theme?
- When using https, WordPress doesn’t use https for CSS and JavaScript, and admin doesn’t work. How do I fix this?
- Responsive Menu: Center vertically [closed]
- WordPress: one page’s content is not centered, other pages all look the same [closed]
- Twenty Twenty Four child theme stylesheet is not being enqueued in admin panel when editing pages