0815

Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

Highlight Author Comments

Make your author comments look fabulous darling! Newer versions of WordPress come equipped with a specific “author” class that may be targeted with the CSS of your choice. For older versions of WordPress, however, you will need to add the custom class attribute with a little PHP magic.

First, open your theme’s comments.php template and add the following code snippet in the (X)HTML element that contains the comment information:

<div<?php if ($comment->comment_author_email == "email@domain.tld") echo ' class="author"'; ?> id="comment-<?php comment_ID(); ?>">
.
.
.
</div>

After changing the email address to that of your own (i.e., the one used for your WP Admin user profile), style it up with a little CSS:

.author {
	background: red !important;
	color: yellow   !important;
	}

You probably don’t want your author comments to appear with yellow text on a red background, but you get the idea. Anything is possible.

For blogs with multiple authors, you can style each of their comments differently as well by using something like this:

<div<?php if ($comment->comment_author_email == "email-01@domain.tld") echo ' class="author-01"'; elseif ($comment->comment_author_email == "email-02@domain.tld") echo ' class="author-02"'; elseif ($comment->comment_author_email == "email-03@domain.tld") echo ' class="author-03"'; ?> id="comment-<?php comment_ID(); ?>">
.
.
.
</div>

Replace each of the email addresses with those of the various authors. Style to taste.

Credit: Nyssa Brown (404 link removed)




0