Support » Fixing WordPress » Show 3 random posts from last 8 posts of a category.

  • Hi! I don’t know how can i do something:

    If my code is:

    <?php
    query_posts(‘cat=3&posts_per_page=3&orderby=rand’);
    while (have_posts ()): the_post();
    echo ”

  • ID) . “‘>”;
    the_title();
    echo ‘
  • ‘;
    endwhile;
    ?>

    I have getting all the posts of category 3. But my question is. Can i get only last 8 posts of category 3? I don’t want 3 of all the posts. I want 3 of last 8 posts. How can i do it?

    Maybe my english is very bad. I hope you understand what i want to say. Thanks!

Viewing 1 replies (of 1 total)
  • Sorry, i didn’t know i have to mark code button:

    <?php
    			 define('WP_USE_THEMES', false);
    			 require_once($_SERVER['DOCUMENT_ROOT'] . '/contenidos/wp-blog-header.php');
    			query_posts('cat=3&posts_per_page=3&orderby=rand');
    			 while (have_posts ()): the_post();
    			 echo "<li><a href='" . get_permalink($post->ID) . "'>";
    			 the_title();
    			 echo '</a></li>';
    			 endwhile;
    			?>
Viewing 1 replies (of 1 total)
  • The topic ‘Show 3 random posts from last 8 posts of a category.’ is closed to new replies.