ユーザーをWordPressのランダムな投稿にリダイレクトしたいですか?
ランダムにブログ投稿を表示することで、訪問者にもっと記事を読んでもらうことができます。そうすることで、サイトに長く滞在してもらい、ページビューを増やすことができる。
この投稿では、WordPressでユーザーを簡単にランダムな投稿にリダイレクトする方法を紹介する。
ユーザーをランダム投稿にリダイレクトするタイミング
ユーザーをランダムな投稿にリダイレクトさせることは、ブログの投稿がたくさんあるにもかかわらず、表示回数が多いのはそのうちの一部だけという場合に便利です。
訪問者をランダムな投稿に送り込むことで、訪問したことのない新しい記事を発見することができる。これにより、WordPressのページビューを増やし、直帰率を減らすことができる。
また、404エラーページに「ランダム投稿」ボタンを追加するのもよいだろう。そうすることで、サイトからの離脱を減らし、さらにコンテンツを探そうと興味を持ってもらえるかもしれない。
ということで、WordPressでユーザーをランダムな投稿にリダイレクトする方法を見てみよう。
動画チュートリアル
動画をご覧になりたくない方は、下のテキスト版をお読みください。
WordPressでユーザーをランダム投稿にリダイレクトする
ユーザーをランダムなブログ投稿にリダイレクトする最も簡単な方法は、Redirect URL to Postを使うことです。このプラグインはリダイレクトURLを作成し、ボタンやメールマガジン、ナビゲーションメニューなど、リンクをサポートする任意の場所に追加することができます。
最初に行う必要があるのは、Redirect URL to Postプラグインをインストールして有効化することです。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。
有効化すると、訪問者を任意のページにリダイレクトするために使用できるさまざまなURLクエリーパラメータに関する情報が表示されます。
ユーザーを任意のWordPress投稿にリダイレクトするには、URLをコピーし、ナビゲーションメニュー、サイドバーウィジェット、コールトゥアクションボタンなど、好きな場所に追加するだけです。
このページから離れてしまった、または誤って閉じてしまった場合、ランダムな投稿にリダイレクトするさまざまなクエリーを以下に示します。http://www.example.com
、ご自身のドメイン名に置き換えてください:
- http://www.example.com/?redirect_to=random&pk_campaign=random. ランダムな投稿にリダイレクトし、訪問をトラッキングする。WordPressサイトの訪問者をトラッキングしたい場合に最適な設定です。
- http://www.example.com/?redirect_to=random&each_once=rewind。Duplicatorを避けてランダムな投稿にリダイレクトし、もう一度やり直す。
- http://www.example.com/?redirect_to=random&count=10。最新の投稿10件の中からランダムな投稿にリダイレクトする。
- http://www.example.com/?redirect_to=random&after=1%20month%20ago。1ヶ月以上前の投稿の中からランダムな投稿にリダイレクトします。
プロのヒント これはオプション設定ですが、プラグイン開発者はURLの最後に&cache=120
パラメータを追加することを提案しています。これにより、ランダムな結果を120秒間保存することができ、ユーザーにとってWordPressサイトの読み込みが速くなります。
また、以下のショートコードを使用して、任意のページ、投稿、またはウィジェット対応エリアに「ランダム投稿」ボタンを追加することもできます:
[redirect_to_post_button]。
ショートコードの設置方法については、WordPressでショートコードを追加する方法をご覧ください。
読者がランダムリダイレクトボタンをクリックすると、WordPressサイト上のランダムなブログ投稿に飛ばされます。
ブロックベースのWordPressテーマを使用している場合は、フルサイトエディターで任意のテンプレートやパターンにこのボタンを追加することもできます。
始めるには、WordPressダッシュボードの外観 ” エディターへ向かいます。
フルサイトエディターを使用してサイトを編集するためのメニュー項目が表示されます。
デモンストレーションのために、先に進んで『テンプレート』を選択する。
ホームページやアーカイブページなど、編集したいテンプレートやテンプレート部分をクリックします。
例として、404ページテンプレートに‘ランダム投稿’ボタンを追加しますが、どのテンプレートを選択しても手順は全く同じです。
WordPressはテンプレートまたはテンプレートパーツのプレビューを表示します。
ランダム投稿ショートコードを追加するには、先に進み、小さな鉛筆のアイコンをクリックします。
それが終わったら、左上の青い「+」アイコンをクリックする。
検索バーに「ショートコード」と入力してください。
適切なブロックが外観されたら、テーマテンプレートにドラッグ&ドロップする。
このブロックに[redirect_to_post_button]
ショートコードを貼り付けるかタイプしてください。
その後、「保存」ボタンをクリックしてください。
さて、WordPressブログにアクセスするだけで、ランダム投稿ボタンが動作しているのを確認できる。
この投稿が、WordPressでユーザーをランダムな投稿にリダイレクトする方法を学ぶのにお役に立てば幸いです。ブログのトラフィックを増やす方法についてのガイド、またはWordPressのSEOプラグインとツールのエキスパートが選ぶベストもご覧ください。
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!
Wesley Huang says
Is that possible to randomly redirect to part of the post? I am thinking of something that allows user to post something under a type, and other user will randomly see one of the post belongs to that category, but not randomly from all the posts
WPBeginner Support says
If you mean you are going to add user-submitted posts then the plugin does have the option to limit the random post selected to those within the specific category or other parameters.
管理者
daniel says
Is there a way to do this mannually ?
WPBeginner Support says
It would require coding knowledge and would not be beginner friendly if you tried to do it manually.
管理者
Xolani says
What parameters to use to redirect users to a random custom post type?
Chris says
You can redirect to a random post from a custom post type by adding the parameter post_type, for example …?redirect_to=random&post_type=product
See all parameters at https://documentation.chattymango.com/documentation/redirect-url-to-post/getting-started-redirect-url-to-post/search-parameters/
Unfortunately, the plugin cannot pick a random post type out of a set of post types, if that’s what you need.
Elena says
Hi,
I have a website created in WordPress.com. I wanted to have a self hosted site so i moved it to Site Ground. I also wanted to have my site in WordPress.org so I could have more freedom to change my site. Can you help me how I can move my site to WordPress.org? Thanks.
WPBeginner Support says
Hi Elena,
Please see our article on how to move from WordPress.com to WordPress.org.
管理者
Rodney Coleman says
Interesting read and very handy plugin. Thanks for the heads up..