i add this code in index.php
.
<div class="Div1"></div>
. then write some css(absolution position) to the Div1
. so when i login in my wordpress. the admin nav will push down some spaces to the site body. so the conetent shows unnormal. now, i want to add a class
to <div class="Div1">
when logins. is there a way to get this.
Leave a Reply
You must be logged in to post a comment.
If you are using the
body_class()
function, a classadmin-bar
will be added automatically when the admin bar is active. For example:You can then use that class in your CSS to specify specific rules:
You can use jquery for this with a
And then use jquery to add class to div
So you would use this
Paste this in your functions.php file in the header.php or a plugin. Your choice. If the add class does not work try finding the div id that div1 class is inside of and use this instead ‘jQuery(“#divclassparent .Div1”).addClass(“logged-in”);’