Walker News

Highlight Author Comment And Pingback In WordPress Theme

If you’re not comfortable with Gravatar displayed on comments in WordPress theme, a simple CSS hack is still possible to highlight author’s comments and pingbacks.

(There is NO bandwidth overhead on web-hosting by turning on Gravatar as the graphics is stream from Gravatar servers! So, why worry to enable Gravatar in WordPress theme?)

The highlighting technique makes site author’s comments and pingbacks appear outstanding in a long list of follow-up. In this, the site readers can easily trace the author’s reply or related topics to questions/discussion on the subject.

Again, WordPress community is not short of plugins to get web design works easily. Otherwise, a simple PHP hack or snippet will do the job too.

To highlight author’s comments and pingback in WordPress theme without using a plugin, you can follow this simple PHP snippet and CSS hack.
  1. Add a CSS style for site author’s comments and pingbacks to the CSS style-sheet of WordPress theme (it’s used to be called style.css), e.g.
    .comm-admin-hack {
    	text-align: justify;
    	clear: both;
    	margin-top: 0px;
    	margin-bottom: 10px;
    	padding: 10px;
    	width:450px;
    	border: #FFA303 2px solid;
    	background: #333333;
    }
    
  2. Locate the comment_text() function in the comments.php template and remark/comment out the function
  3. Insert this PHP snippet right after the remarked/commented comment_text() function.
    The blue colour PHP code should be customized for your case; the red colour is the original line remarked in previous step.
    <?php 
    
    
       $authurl = substr($comment->comment_author_url,7,18);
    
       if (the_author('', false) == get_comment_author() || $authurl == 'www.walkernews.net'){
          echo "<div class='comm-admin-hack'>";
       } else {
          echo "<div class='commenttext'>";
       }
    
    
       comment_text();
    
       echo "</div>";
    
    ?>
    

That’s all to enable author’s comments and pingbacks highlight feature.

Together with the trick of enabling Gravatar in WordPress theme, the highlight effects will looks sharper and better.

Custom Search

2017  •  Privacy Policy