例えば、 WordPress Kboard掲示板のどの文が毎日 平均 25回以上照会がされると、「Hot」というラベルを付けたい場合は、次のコードをスキンフォルダ内の「list.php」ファイルの適切な場所に追加します。
<!-- For outputting "Hot" Label --> <?php $now = date("Y-m-d"); $last_active = date("Y-m-d", strtotime($content->date)); $now = new DateTime($new); $last_active = new dateTime($last_active); $interval = $last_active->diff($now); $difference = $interval->format('%R%a days'); $difference = $difference + 1; /* The date difference plus 1 */ $hot_views_per_day = 25; /* The number of views per day which will be set as hot topics */ $total_counter = $content->view; /* View count of the current topic */ $acutal_views_per_day = $total_counter / $difference; /* View count per day */ if ($acutal_views_per_day >= $hot_views_per_day) { echo '<img style="margin-bottom: -8px; border:0!important; box-shadow: none!important;" src = "' . home_url( '/' ) .'wp-content/uploads/2015/07/hot.png" alt="hot">'; } ?> <!-- End -->
画像は、適切な「Hot」のアイコンに置き換えたり、テキストに置き換えCSSでレイアウトを調整することもできます。 そしてHot項目に指定する基準視聴も適切に調整してください。 上記のコードは、テストを経ていない。 よくあることを確認してない場合は、コメントでお知らせください。
추가: home_url( '/')サイトのURLを出力します(ここ を参照)。 イメージファイルのパスが www.abc.com/wp-content/uploads/.../hot.pngであれば、 。 home_url( '/')。 「/wp-content/uploads/.../hot.png"に変更します:
추가:ホットラベルをイメージの代わりに文字で実装するには、 タグを適切なコードに変更します。 (例えば、 HOT)
成功しました! 本当にありがとうございました~~ !!!!
もちろん可能です。 (最初は1つのコードで作ったが、わざわざ分離したものです。)
時間になると、一度上げてみます。
参考までに、PHPをよく分からないけれどもHot部分のコードとNew部分のコードを詳しく見てみれば簡単に作成することができます。