WordPress.org

Ready to get started?Download WordPress

Forums

Random Post just like the regular posts (1 post)

  1. gengivas
    Member
    Posted 7 years ago #

    Hi!

    I've tried a lot of codes and plugins to do a random post. Some of them worked pretty well, but not the way I want. I want to display a random post on the front page, but I want that the random post looks like a regular post (with the title, the content, the date... everything!)

    I tried the Kafkaesqui's code:

    <?php
    $rand_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY RAND() LIMIT 1");
    query_posts("p=$rand_id");
    ?>

    http://wordpress.org/support/topic/40818?replies=24

    It's almost what I want... The only problem is that when I use this code, my index page only shows the random post (all the rest disappear!)

    I want to show 16 post on my index: 1 random post at the top, and 15 "regular" posts after that.

    What can I do?
    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags