Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressで最新のコメントを最初に表示する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressで最新のコメントを最初に表示しますか?

初期設定では、WordPressは古いコメントを最初に表示します。しかし、最新のコメントが最初に表示されるように変更することもできます。

この投稿では、WordPressでコメントを簡単に並べ替え、最新のコメントを最初に表示する方法を紹介します。

Display newer comments on top in WordPress

WordPressで最新のコメントを最初に表示する理由とは?

WordPressで最新のコメントを最初に表示することは、コメントを増やし、活発な議論を促すのに適している。

WordPressの初期設定では、一番古いコメントが一番上に表示されますが、これでは新しい会話が生まれないかもしれません。最新のコメントを最初に表示することで、訪問者が進行中のディスカッションに参加する動機付けとなり、WordPressブログのユーザーエンゲージメントを高めることができます。

さらに、最新のコメントをハイライトすることで、サイトの見た目が新鮮になり、より魅力的になるため、WordPressのページビューを増やし、直帰率を下げる可能性があります。

An example of recent comments in a WPBeginner article

ということで、WordPressで簡単に最新のコメントを最初に表示する方法を見てみましょう。以下のクイックリンクから、使いたい方法にジャンプしてください:

方法1:WordPressの設定で新しいコメントから表示する(プラグインなし)

コメントを並べ替える最も簡単な方法は、WordPressダッシュボードの設定 ” ディスカッションにアクセスすることです。

Showing newest comments first in the WordPress settings screen

他の「その他のコメント設定」セクションで、「コメントは…で表示する」を見つける。

初期設定では「各ページの一番上にある古いコメント」に設定されていますが、このドロップダウンを開き、代わりに「新しいコメント」を選択することができます。

Showing the most recent comments first in WordPress

設定が完了したら、ページを一番下までスクロールし、「変更を保存」をクリックして設定を保存します。

WordPressブログにアクセスすると、最新のコメントが最初に表示されます。

WordPressのディスカッション設定の詳細については、WordPressのコメントをモデレートするための初心者ガイドをご覧ください。

方法2:WordPressでコメントする順番を手動で設定する(コード方式)

最初の方法が最も簡単ですが、WordPressの設定が機能しない場合もあります。

例えば、WordPressの初期設定を上書きするカスタマイザーのWordPressテーマを作成したとします。

その場合、コードを使って最新のコメントを最初に表示することができる。

チュートリアルでは、テーマのfunctions.phpファイルにカスタムコードスニペットを追加するように書かれていることがよくあります。しかし、コードのちょっとした間違いがWordPressの一般的なエラーを引き起こしたり、サイトを完全に壊してしまう可能性があるため、この方法はお勧めしません。

そのため、WPCodeの使用をお勧めします。WordPressのコアファイルを編集することなく、WordPressにコードスニペットを追加する最も簡単で安全な方法です。

最初に行う必要があるのは、あなたのサイトに無料のWPCodeプラグインをインストールして有効化することです。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

有効化したら、WordPressダッシュボードのCode Snippets “ Add Snippetにアクセスする必要があります。

The WPCode WordPress code snippet plugin

ここでは、サイトに追加できる既製のスニペットがすべて表示されます。

独自のスニペットを追加したいので、「カスタムコードを追加」にマウスオーバーし、「スニペットを使用」をクリックするだけです。

Changing the order of WordPress comments using code

はじめに、カスタム・スニペットのタイトルを入力します。これは、WordPressダッシュボードでコードスニペットを識別するのに役立つものであれば何でも構いません。

その後、「コードタイプ」のドロップダウンを開き、「PHPスニペット」を選択する。

Adding custom PHP to your WordPress pages and posts

では、次のスニペットをコードエディターに貼り付けてください:

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サイト全体でスニペットが使用されるように、「自動挿入」を選択します。

その後、『場所』のドロップダウンを開き、『どこでも実行』を選択する。

Run the comment snippet everywhere on your WordPress website

それが終わったら、画面を一番上までスクロールし、「Inactive」トグルをクリックして「Active」に変更する。

最後に「スニペットを保存」をクリックする。

Saving a recent comments snippet in WordPress

スニペットをあなたのサイトで有効化するには、「Inactive」スライダーをクリックして「Active」にする。

最後に「更新」をクリックする。

Showing newest comments first using code

WordPressサイトにアクセスすると、コメント欄の一番上に最新のコメントが表示されます。

このコードはWordPressの設定を上書きしますのでご注意ください。最も古いコメントを最初に表示するように戻したい場合は、コードスニペットを無効化する必要があります。

コード・スニペット “ コード・スニペットにアクセスしてください。ここでコメントするスニペットを見つけ、そのトグルをクリックして有効化(青)から非有効化(灰色)にします。

Showing newest comments first using WPCode

ボーナスヒント: Thrive Commentsでコメントへのエンゲージメントを高める

WordPressで最新のコメントを表示することは、ユーザーエンゲージメントを高める一つの方法に過ぎません。もう一つの方法は、Thrive Commentsのようなコメントプラグインを使用することです。

私たちが試したすべてのコメントプラグインの中で、Thrive Commentsはコメント欄を改善するための最も包括的な機能を持っています。

例えば、コメントコンバージョン機能を使って、コメントした人をコメントを残した後の特定のアクションにリダイレクトすることができます。これは、カスタマイザーページ、関連投稿、またはThrive Leadsのオプトインフォームにすることができます。

Thrive Comments' post-comment actions

その結果、コメントする人をあなたのサイトに長く滞在させることができる。

このコメントプラグインの詳細については、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.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

22件のコメント返信を残す

  1. 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!

  2. 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!

  3. 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

  4. 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.

  5. 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.

  6. 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.

  7. 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!

  8. 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.

  9. 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”

  10. 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.

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。