Get random post in Wordpress

后端 未结 5 1205
你的背包
你的背包 2021-02-19 12:00

How do I get a random post in Wordpress?

I would like to display a button on a page that, when pressed, goes to a random post from the blog. I don\'t want a random post

5条回答
  •  無奈伤痛
    2021-02-19 12:38

    Another Simple solution to display Random Post

    1.First a create a custom page template. Name it as random post or a name of your choice!

    2.Open the page and remove the default wp loop and Paste the code below

    3.To change the no of post change the number ‘1’ to your choice!

      'rand', 'showposts' => 1));
    if (have_posts()) :
    while (have_posts()) : the_post(); ?>
     
    

    source: http://www.yengkokpam.com/displays-random-posts-in-a-page/

提交回复
热议问题