Tutorials

Highlight author's comments on WordPress blog

A simple trick to make comments from the original post author stand out a bit more in the comment listing - useful for seeing replies to comments.

First you need to create a style to apply to highlighted comments on your blog. To do this, either in the admin editor or via SSH/FTP edit the file style.css.

Add a line that applies a style to a class called authorstyle:

python
:::css

.authorstyle { background-color: #fffddf !important; }

Here we've set the background to a nice yellow.

Next find the comments.php file in your theme folder and look for the following line:

python
:::php

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

And replace it with:

python
:::php

<li class="<?php if ($comment->user_id == 1) $oddcomment = "authorstyle"; echo $oddcomment; ?>"></li>

What this is doing is checking whether the user_id of the comment poster equals 1 (the admin user - who set up the blog) and if so showing the comment as highlighted. This will only work on a single-user blog (i.e. if you have more than one author their posts will not be highlighted).

Create GUI Applications with Python & Qt5 by Martin Fitzpatrick

(PyQt5 Edition) The hands-on guide to making apps with Python — Over 15,000 copies sold!

More info Get the book

Elsewhere

Display external RSS feeds on your WordPress blog
Syntax highlighting with Django and Markdown
Wooey
Simple, automated web UIs for Python scripts
Drag & Drop Widgets with PySide6