Forums

Random Posts on a Page (5 posts)

  1. vpotok
    Member
    Posted 2 years ago #

    I would like to create a page where all of the posts from all of my categories are listed by randomized every time. Is this possible?

    thank you!

  2. racer x
    Member
    Posted 2 years ago #

    <ul><li><h2>A random selection of my writing</h2>
        <ul>
     <?php
     $rand_posts = get_posts('numberposts=5&orderby=rand');
     foreach( $rand_posts as $post ) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
        </ul>
     </li></ul>

    straight from http://codex.wordpress.org/Template_Tags/get_posts

  3. vpotok
    Member
    Posted 2 years ago #

    I want to add this only to a particular page though not all of them so I'm not sure where to put that?

  4. vpotok
    Member
    Posted 2 years ago #

    also, is this just a list of posts? I want them to actually be displayed fully, as if on the front page. I want this to be a random page.

  5. racer x
    Member
    Posted 2 years ago #

    If you want a page to do something that no other page does by default, then you need a specific template for this page.

    This may be beyond what you know about how wordpress works.(?)

    The front page is usually not really showing all of the posts' content. It is just an intro with a "read more" link to the full story.

    Time to dig into the codex my friend:
    http://codex.wordpress.org/Pages

Topic Closed

This topic has been closed to new replies.

About this Topic