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
- WordPress, AJAX and pre_get_posts using conditional tags
- Incorrect MIME type for assets with Valet
- How to display pictures from database?
- How to add condition in wordpress loop? [closed]
- Customize position of social icons in upme plugin [closed]
- 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
- two columns of posts on homepage, one of them “favorites”
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- 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
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Is_front_page inside header.php is always returning true
- If tag equals then show else show
- Which is the correct way to conditionally enqueue a CSS file?
- Custom Background by Page IDs
- proper way to add css using functions.php?
- WordPress style.css not updating, only after theme reload
- 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
- Odd / Even posts add class minus first post
- Advanced Custom Fields – display label and value only if value entered
- Change CSS based on is_user_logged_in
- PHP conditional script issue
- RTL Stylesheet Confusion with WordPress
- Correct way to enqueue page specific CSS file
- Wrapping a Sidebar within
- How to check if the current page is at a specified path in the URL?
- Add Codepen animation as Preloader to WordPress
- WordPress wp_add_inline_style unable to give hex colors?
- Reduce size of responsive title
- How to make container class in PHP
- How to create table in wordpress without plugin? [closed]
- Conditional statement for dates
- WordPress archive page showing 404 Error [duplicate]
- How can I display a div ONLY if it is not a certain term page
- PHP in CSS file?
- Don’t show certain div on front page?
- Clickable image link sends people to wrong URL
- Styling the second sidebar
- If ‘editor’ is empty, then
- Liking a facebook page from wordpress website?
- trouble with page_id & highlighting current page
- Last class on last headline?
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- Creating a mobile site by adding a new class to the body tag from functions.php
- wordpress admin plugin menu custom css
- How to add drag and drop functionalities to a div inside option panel
- Removing WordPress Footer -without access to PHP code?
- Change “No Comments” link to “My String” on Blog Post (Find Snippet in Code or use CSS, PHP Solution) [closed]
- How to remove sidebar primary widget on Mobile on category page [closed]
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- How to Change CSS Colors from Custom Plugin Settings Page
- Get ACF options field in PHP acting as CSS
- Where can I find the inline-css of my theme header?
- CSS change in woo commerce Place Order Text [closed]
- Undefined index for default custom theme option
- Post repeated when opening in overlay, how do I solve this? [closed]
- Remove conditional tag from header
- Menu Custom Data Attributes
- Highlight the links without using dropdown
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Add New Text Box To WordPress Twenty Seventeen Header
- Split site title and apply different classes
- Display an image based on field value
- How to modify mobile nav menu text in theme
- Website completely messes up when logging out
- Issue Enqueueing WordPress style.css
- Need help removing […] after excerpt
- Dividing the loop to style post differently
- Conditional featured image with youtube thumbnail
- jQuery accordion menu
- Twentyfifteen style author comment
- Link to page with posts of specific type
- How to make a conditional statement within $output in shortcodes.php?
- Extend Menu Walker Output
- How to add new CSS file to new PHP file
- Applying CSS on PHP variable [closed]
- Conditionally load class in the comment section of the post page
- Dynamic CSS through PHP issue
- “if parent category is” conditional?
- Assign Custom classes to every Excerpt
- Conditional for Post Format
- How to make changes to style.php [closed]