WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Random Post from a category (3 posts)

  1. techmulla
    Member
    Posted 5 years ago #

    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

  2. nex2nun
    Member
    Posted 5 years ago #

    Have a look at this similar request in the forums.

    http://wordpress.org/support/topic/171753?replies=10

    Hope this helps!
    Derek M.

  3. techmulla
    Member
    Posted 5 years ago #

    thankyou thankyou thankyou.

Topic Closed

This topic has been closed to new replies.

About this Topic