1. 先於佈景主題的CSS設計一個與一般留言不同的樣式,並為它取一個特別的名稱(class)
    例如:

    .authorcomment {
      background:#CEE1EF;
    }
    
  2. 打開佈景主題的comments.php,找到
    <?php foreach ($comments as $comment) : ?>
    

    在這後面的幾行,會看見留言內容的樣式,類似

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

    在這裡面加入php程式碼,讓他看起來變這樣

    <li class="<?php if ($comment->comment_author_email == "author@example.com") echo 'authorcomment'; else echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    

    請將author@example.com改成你留言時慣用的信箱就可以了,這邊出現的信箱不會輸出在HTML原始碼內,所以不需要擔心

  • 延伸運用:依照不同訪客給予不同的樣式
    <li class="<?php if ($comment->comment_author_email == "author@example.com") echo 'authorcomment'; else if ($comment->comment_author_email == "friend1@example.com") echo 'friend1'; else if ($comment->comment_author_email == "friend2@example.com") echo 'friend2'; else echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    
Popularity: 6% [?]