WordPress.org

Support

Support » Themes and Templates » [Resolved] Random Post from a category

[Resolved] Random Post from a category

  • I have looked around the forums before posting. I want to display a random post from a single category say “life”. How to achieve it? I am a zero at php. currently i am using the following lines of code.

    <div id="content">
    <!--Get the last post from Life category. -->
    
    <?php query_posts('category_name=Life&showposts=1'); ?>
    <!-- Start Stylyzing Prdoduct -->
    <?php while (have_posts()) : the_post(); ?>
    
    <h1><?php the_category(' '); ?></h1>
    
    <?php the_title('<h2>', '</h2>'); ?>
    <?php the_excerpt(); ?>
    
    <?php endwhile;?>

    this code shows the latest from the life category. how to get a random post from life category?

    Thanks in advance

    //Techmulla

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Random Post from a category’ is closed to new replies.