[resolved] Rotate or Shuffle My Posts (4 posts)

  1. shawngoesgreen
    Posted 6 years ago #

    I have a site with my art portfolio. Each piece is a photo with a description. I would like to randomly have an older post come up to the first place on the home page. Is there a way to do this manually or with a plugin?

    The plugin "rotating posts" is not what I want it to do but it looks like a great plugin anyway.

  2. MichaelH
    Posted 6 years ago #

    This will retrieve and display one random post.

      'orderby' => 'rand',
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 1,
      'caller_get_posts'=> 1
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    wp_reset_query();  // Restore global post data stomped by the_post().

    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

  3. shawngoesgreen
    Posted 6 years ago #

    Thanks for the help Michael.

  4. newftronics
    Posted 5 years ago #

    My question is the same as shawngoesgreen however I do not know what to do with the Script that MichaelH has provided. I am a Newbee to WordPress so I am sure this question will seem to be easy to most. Any help would be greatly appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic