Skip to content Skip to sidebar Skip to footer

How Can I Display A Div Box With Id Only For The Corresponding Author Of The Wordpress Page?

How can I display a div box with ID only for the corresponding author of the wordpress page? for example when testuser is logged in he should see a div box with id='author' inside

Solution 1:

Although, your question is not so clear about your requirements. What I understood is you are looking for an Author box on the post, in the standard WordPress theme hierarchy it is called Single, and the file is single.php

You can try by adding div conditionally checking for the post author.

if( is_user_logged_in() && is_author(get_current_user_id()) ) {

    // add your div code here for the post author.

}

If that is not the solution you are looking for, please share some code samples you are working on with a better explanation.

Solution 2:

i made it for the admin but i want the id to be visible only to the author of the post.

example:

if the author is logged in he should see the content with the id=author.

but

if another user is logged in he should not see the content with the id.

/* hide role-specific div */#author {
  display: none;
}

body.logged-in.admin-bar#author {
  /* Admin is logged in*/display: flex;
}

Post a Comment for "How Can I Display A Div Box With Id Only For The Corresponding Author Of The Wordpress Page?"