WordPressで最新のコメントを最初に表示しますか?
初期設定では、WordPressは古いコメントを最初に表示します。しかし、最新のコメントが最初に表示されるように変更することもできます。
この投稿では、WordPressでコメントを簡単に並べ替え、最新のコメントを最初に表示する方法を紹介します。
WordPressで最新のコメントを最初に表示する理由とは?
WordPressで最新のコメントを最初に表示することは、コメントを増やし、活発な議論を促すのに適している。
WordPressの初期設定では、一番古いコメントが一番上に表示されますが、これでは新しい会話が生まれないかもしれません。最新のコメントを最初に表示することで、訪問者が進行中のディスカッションに参加する動機付けとなり、WordPressブログのユーザーエンゲージメントを高めることができます。
さらに、最新のコメントをハイライトすることで、サイトの見た目が新鮮になり、より魅力的になるため、WordPressのページビューを増やし、直帰率を下げる可能性があります。
ということで、WordPressで簡単に最新のコメントを最初に表示する方法を見てみましょう。以下のクイックリンクから、使いたい方法にジャンプしてください:
方法1:WordPressの設定で新しいコメントから表示する(プラグインなし)
コメントを並べ替える最も簡単な方法は、WordPressダッシュボードの設定 ” ディスカッションにアクセスすることです。
他の「その他のコメント設定」セクションで、「コメントは…で表示する」を見つける。
初期設定では「各ページの一番上にある古いコメント」に設定されていますが、このドロップダウンを開き、代わりに「新しいコメント」を選択することができます。
設定が完了したら、ページを一番下までスクロールし、「変更を保存」をクリックして設定を保存します。
WordPressブログにアクセスすると、最新のコメントが最初に表示されます。
WordPressのディスカッション設定の詳細については、WordPressのコメントをモデレートするための初心者ガイドをご覧ください。
方法2:WordPressでコメントする順番を手動で設定する(コード方式)
最初の方法が最も簡単ですが、WordPressの設定が機能しない場合もあります。
例えば、WordPressの初期設定を上書きするカスタマイザーのWordPressテーマを作成したとします。
その場合、コードを使って最新のコメントを最初に表示することができる。
チュートリアルでは、テーマのfunctions.phpファイルにカスタムコードスニペットを追加するように書かれていることがよくあります。しかし、コードのちょっとした間違いがWordPressの一般的なエラーを引き起こしたり、サイトを完全に壊してしまう可能性があるため、この方法はお勧めしません。
そのため、WPCodeの使用をお勧めします。WordPressのコアファイルを編集することなく、WordPressにコードスニペットを追加する最も簡単で安全な方法です。
最初に行う必要があるのは、あなたのサイトに無料のWPCodeプラグインをインストールして有効化することです。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。
有効化したら、WordPressダッシュボードのCode Snippets “ Add Snippetにアクセスする必要があります。
ここでは、サイトに追加できる既製のスニペットがすべて表示されます。
独自のスニペットを追加したいので、「カスタムコードを追加」にマウスオーバーし、「スニペットを使用」をクリックするだけです。
はじめに、カスタム・スニペットのタイトルを入力します。これは、WordPressダッシュボードでコードスニペットを識別するのに役立つものであれば何でも構いません。
その後、「コードタイプ」のドロップダウンを開き、「PHPスニペット」を選択する。
では、次のスニペットをコードエディターに貼り付けてください:
function wpb_reverse_comments($comments) {
// Check comment order
$comment_order = get_option('comment_order');
// if comment order is default then change it.
if ( $comment_order == 'asc' ) {
return array_reverse($comments);
}
}
add_filter ('comments_array', 'wpb_reverse_comments');
このコードは、WordPressの設定をチェックすることから始める。もしコメントの順序が最も古い順に設定されている場合、このコード・スニペットはこれを上書きし、新しいコメントが最初に表示されるようにします。
その後、「インサーター」セクションまでスクロールします。すでに選択されていない場合は、WordPressサイト全体でスニペットが使用されるように、「自動挿入」を選択します。
その後、『場所』のドロップダウンを開き、『どこでも実行』を選択する。
それが終わったら、画面を一番上までスクロールし、「Inactive」トグルをクリックして「Active」に変更する。
最後に「スニペットを保存」をクリックする。
スニペットをあなたのサイトで有効化するには、「Inactive」スライダーをクリックして「Active」にする。
最後に「更新」をクリックする。
WordPressサイトにアクセスすると、コメント欄の一番上に最新のコメントが表示されます。
このコードはWordPressの設定を上書きしますのでご注意ください。最も古いコメントを最初に表示するように戻したい場合は、コードスニペットを無効化する必要があります。
コード・スニペット “ コード・スニペットにアクセスしてください。ここでコメントするスニペットを見つけ、そのトグルをクリックして有効化(青)から非有効化(灰色)にします。
ボーナスヒント: Thrive Commentsでコメントへのエンゲージメントを高める
WordPressで最新のコメントを表示することは、ユーザーエンゲージメントを高める一つの方法に過ぎません。もう一つの方法は、Thrive Commentsのようなコメントプラグインを使用することです。
私たちが試したすべてのコメントプラグインの中で、Thrive Commentsはコメント欄を改善するための最も包括的な機能を持っています。
例えば、コメントコンバージョン機能を使って、コメントした人をコメントを残した後の特定のアクションにリダイレクトすることができます。これは、カスタマイザーページ、関連投稿、またはThrive Leadsのオプトインフォームにすることができます。
その結果、コメントする人をあなたのサイトに長く滞在させることができる。
このコメントプラグインの詳細については、Thrive Themes Suiteの詳細レビューをご覧ください。
WordPressで最新のコメントを表示する方法について、この投稿がお役に立てれば幸いです。WordPress サイトでユーザー登録を許可する方法や、WordPress のエキスパートが選ぶ最高のメンバーシッププラグインもご覧ください。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Lisa says
I don’t have the “other comments” option. What do I need to do to make it available?
WPBeginner Support says
Are you on WordPress.com?
管理者
M Smith says
Thanks so much! Had this fixed in a few seconds!
WPBeginner Support says
You’re welcome
管理者
Jo Smith says
Wow this was really helpful! Thank you.
ZYnth RObinson says
thank you! this is the only thing that worked for me!!
Andrei says
Thank you for this tip: $comments = array_reverse($comments);
I tried the admin option of showing newest comments at the top and it didn’t work, but your code worked. Thank you!
rexcollin91 says
I think this is one of the most important info for me. And i’m glad reading your article. But should remark on some general things, The website style is wonderful, the articles is really excellent
jackmoores says
Hey I discovered this web site to be actually interesting! Bookmarked!
tonchavez17 says
I am typically to running a blog and i really respect your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for new information.I am typically to running a blog and i really respect your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for new information.
shainatim says
I prefer method 2, it is easier than codes. I hate codes coz I am not good at it. Thanks for the plugin.
Jim Hutchinson says
@Grace T In your Dashboard, drop down the Plugins list and click Add New. In there you will see a link on top to Upload. Click that and then the Browse button to locate the ZIP file you downloaded. Then click Install Now.
You may be prompted for your FTP login details. If you are, enter it and click the Proceed button. The next page will show 2 links: Activate Plugin and Return to Plugins page. Click Activate Plugin to start using it now.
Grace T says
I downloaded the plugin, but I’m really not great with technology, so how do you activate it? This sounds like a stupid question, but I really need help!
Udegbunam Chukwudi says
@Jim Hutchinson: That discussion settings stuff doesn’t work at all.
@Editorial Staff: It would have been better if you just said replace
with
.
I had to go to the wordpress forum to find this solution.
Jim Hutchinson says
A plugin is not needed for this. Just go into the Discussion Settings and select how you want the comments to show, older or newer.
“Comments should be displayed with the [older][newer] comments at the top of each page”
Grace T says
Oh, I just realised you’re right! Thankyou!
Chijo says
I see that this plugin has not been updated since 2008 so I’m wary about using it.
Also, I do see the setting in Discussion and have set my comments to display Newest at the top, but that doesn’t seem to work.
Anyone have any thoughts?
thanks
Editorial Staff says
Use the default option in the Discussion area.
Stefan Pinto says
Will it work with Disqus?
Kevin says
I am having a custom WordPress theme developed by someone from elance.com and I would like to know whether or not I’ll be able to install plugins such as Simple Reverse Comments because my theme is custom. Can you shed light on this? Maybe I should cut my losses and go with something like the Thesis theme which is more cookie-cutter? Thank you for your blog, it has been very helpful to me.
Editorial Staff says
You should be able to install this plugin in your custom theme.
管理者