I am planning to make a website where non website members should see a different view of the footer.

Is this possible using css only?

  • For non members you are making changes in css or in html or in both of footer? – Rishabh Oct 4 '16 at 7:41

When a user is logged in, WordPress adds the class logged-in to the body tag, so you can target CSS differently for logged in users.

body > footer {
    background: black;

body.logged-in > footer {
    background: red;

for example.

This is only good for cosmetic changes though. Don't try to use it to hide information from non-logged in users as the content is still in the HTML.

  • Did this work for you? If so then by all means accept the answer! – Andy Macaulay-Brook Oct 14 '16 at 11:43

If your theme is decently made, there will be a class logged-in added to the body whenever a user is logged in. You could use this class to differentiate the view for members (if they are logged in) and non-members.

Beware that the html sent to the browser will be identical in both cases. This means users can add/remove the logged-in tag in their browser and the css will give the other view. So, this is not a good course if you want to show exlusive information to members. Non-members will be able to see it in the html source.


You can do this with CSS only but is not safe if you want to display information for only logged in users. Because they can rename the 'logged-in' class in an inspector.

You can use the function is_user_logged_in()and put it in an if else statement for showing different footer styles or HTML markup. https://developer.wordpress.org/reference/functions/is_user_logged_in/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.