Friday, 27 July 2012

HIGHLIGHT ADMIN COMMENTS IN WORDPRESS

If you receive a lot of comments on your wordpress site and you need a quick way for users to find replies from you, the admin. Then this snippet is perfect for you!


Note: The image above is achieved with a bit more styling then in this snippet, but is easily achieved. This snippet simply styles the background color.

How it works is simple, you specify a user id to add a custom class to. It then checks the user id of the user commentating. If the id matches then it will add the custom class to that comment. In this case we will use user id 1. Which is the main account that created the wordpress website.

Read on to learn how…
STEP 1: EDITING THE COMMENTS.PHP FILE

In this step you need to open up comments.php from your theme folder. In this folder you need to find a line that looks like this:

<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">

Replace the above line with the following…

<li class="<?php
/* Only use the adminComment class from style.css if the user_id is 1 (admin) */
if (1 == $comment->user_id)
$oddcomment = "adminComment";
echo $oddcomment;
?>" id="comment-<?php comment_ID() ?>">

STEP 2: ADDING STYLE

Now open up your CSS stylesheet, usually style.css within your theme folder. Add the following to to it:

.adminComment {
background-color: #1e7c9a !important;
}

…and that is all, if you need a hand just comment and one of us will get back to you.

Ditulis Oleh : Unknown // 21:42
Kategori:

0 comments:

Post a Comment

 

Followers

Powered by Blogger.