Skip to main content

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.

Comments

Popular posts from this blog

75 Surprisingly Creative Facebook Timeline Covers

Now that you have shifted to “Facebook Timeline” to display you profile in a better way, get creative with it. Facebook timeline gives you a chance to turn you profile exclusive and innovative. Putting up a personal picture as cover, will only make you look outdated. You can try some exciting covers to design your very own Facebook profile in distinguished style. We have scrounged through web to pick 75 amazing Facebook Timeline covers for this list. Unique cover pictures can give your timeline a different-from-the-rest look. You can create your own creative covers picking ideas from these cool pictures listed below. If you like this article, you might be interested in some of our other articles on  Facebook Scripts, Best Facebook Apps, Best Facebook Games, and Facebook Tips You Should Check . Ekkapong Techawongthaworn Be a brand ambassador and flaunt your fanaticism for gadgets and shopping on your cover. Ekkapong Techawongthaworn Gabriel Fort A snapshot of an App...

PHP File Upload

With PHP, it is possible to upload files to the server. Create an Upload-File Form To allow users to upload files from a form can be very useful. Look at the following HTML form for uploading files: <html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> Notice the following about the HTML form above: The enctype attribute of the <form> tag specifies which content-type to use when submitting the form. "multipart/form-data" is used when a form requires binary data, like the contents of a file, to be uploaded The type="file" attribute of the <input> tag specifies that the input sho...

Send Mail using mail function in PHP

$to = "admin@user.vn"; $subject = "User.vn"; $body = "Body of your message here you can use HTML too. e.g. <br> <b> Bold </b>"; $headers = "From: Peter"; $headers .= "Reply-To:  info@yoursite.com "; $headers .= "Return-Path: mailto:info@yoursite.com"; $headers .= "X-Mailer:PHP5"; $headers .= 'MIME-Version: 1.0"; $headers .= 'Content-type: text/html; charset=iso-8859-1"; mail($to,$subject,$body,$headers);