You might want to consider using the WordPress function body_class()
<body <?php body_class($class); ?>>
Then you could use the body class as your current page reference.
This function is for example used by the Twenty-Twelve theme.
For a single post it will become
<body class="single single-post ...">
and for the home page:
<body class="home blog ...">
You can read more about this function in the Codex here:
http://codex.wordpress.org/Function_Reference/body_class
Edit:
I know you can do this with for example body_class() if you want to
add classes to BODY. But how do I do this with a DIV?
You could use it in your div
tag:
<div <?php body_class(); ?>></div>
but it should be sufficient to have this only in the body
tag.
Related Posts:
- Trying to use Ternary operators with WP Conditionals
- conditional statement for custom taxonomy
- Can I set up a hover animation in CSS depending on a PHP conditional?
- Multidimensional Array
- conditional: if is page, and all subpages
- If Month=Particular month display content [closed]
- Load slideshow.css file only if Slideshow is checked / on
- the_author_posts_link css class
- WordPress Shortcode and Dynamic CSS
- Current post’s author name in the author meta tag
- Conditional Statement – check if post has an attachment image
- wp enqueue style and style sheet depth
- CSS saved & enqueued, but wordpress doesn’t load css text, only file
- WordPress loop specific thumbnail size
- Is it possible to use the featured image of a page as a css background without inlining?
- How to display a value from a radio button in the options menu in wordpress
- How should I best target dynamically served content?
- Using is_page() in functions.php not working at all
- How to scale image with equal width and height without distortion?
- php syntax – how to concatenate properly – echo bloginfo(‘stylesheet_directory)
- How to enqueue CSS and JS only on specific template?
- An unwanted inline style is added to my body tag
- Problem adding class to body_class
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Redirect to a different page through registration, depending on page
- What is the correct way to write this conditional statement?
- Selectbox in admin panel function linking to CSS
- Using if/else statements with output from theme options
- How to display pictures from database?
- Gravity form built in Captcha
- How does wp_enqueue_scripts work?
- two columns of posts on homepage, one of them “favorites”
- Whats the proper way to use a php stylesheet in a wordpress theme? [duplicate]
- custom css for admin only
- responsive.css in the WordPress should be prioritized
- WordPress style.css not updating, only after theme reload
- Adding logo to WordPress header
- Thumbnails appear to be zoomed
- height should be set to auto to avoid pixelation in the post thumbnail function
- Odd / Even posts add class minus first post
- Add Codepen animation as Preloader to WordPress
- Reduce size of responsive title
- Conditional statement for dates
- WordPress archive page showing 404 Error [duplicate]
- Clickable image link sends people to wrong URL
- How to add drag and drop functionalities to a div inside option panel
- Removing WordPress Footer -without access to PHP code?
- CSS change in woo commerce Place Order Text [closed]
- Post repeated when opening in overlay, how do I solve this? [closed]
- Add New Text Box To WordPress Twenty Seventeen Header
- Split site title and apply different classes
- Need help removing […] after excerpt
- jQuery accordion menu
- Twentyfifteen style author comment
- How to make a conditional statement within $output in shortcodes.php?
- Extend Menu Walker Output
- Dynamic CSS through PHP issue
- How to make changes to style.php [closed]
- Create Columns with Custom Walker and CSS Classes
- Background image no longer fits to screen now that project is in php files
- Why would the child theme load in the Customize preview, but not on the site itself?
- How to make only the valid active page of a multilevel menu active with – “.nav li.current-menu-item a”?
- echo cutom css code to WordPress page template file ? is this safe?
- I can’t go to the page archive-{post_type}.php
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- I have a background-image in css file but don’t show in site.how to fix this prblm. i sent screenshot. thx
- Trying to generate a CSS file in wordpress uploads folder
- WP Website is shown in HTML
- I cannot find the wordpress.scss file that my live site is pulling from
- I have a lot of JavaScript erorrs after SSL someone can help me?
- I got big white screen when i attach main style sheet of Html in functions.php
- Add code to the header of posts by particular author
- register dependency css and js inside a plugin class
- Add a default style if no Featured image is selected
- Styling a specific post after hovering over it
- custom field – changing an element or background of id div – different versions not working
- CSS loading as empty file in Custom Theme
- user update profile for custom code
- How limit the width of a fixed menu-bar on scroll?
- Where to find the html for WordPress site? [closed]
- How to remove image on single product and get product to span page?
- widget: input the px value from user and use it as inline style in widget function
- Jetpack: Display Site Title when no Site Logo
- Show contact 7 form in popup
- How Can I Center the Logo in the Navigation Menu? [closed]
- How to change the menu color
- Custom Meta Box If Else Statement
- Converting Menu Links to List Elements
- Conditional in foreach loop is outputting content twice
- How to get shared CSS body class between translated WPML pages [closed]
- How do I reformat this to add php inside php?
- Advanced custom fields Repeater conditional statement not working [closed]
- How to customize posts in WordPress by using HTML and CSS?
- How to create and add js and css file when server is not on my PC?
- which php or css file has generated an inline style in WordPress that overwrites my css
- Header location [closed]
- Blog listing not showing dates for every post and arrow missing off image
- How to create different templates for woocommerce single-product.php?
- WordPress Block Editor Gutenberg running code inside ! is_admin()