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

  1. techmulla
    Posted 7 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


  2. nex2nun
    Posted 7 years ago #

    Have a look at this similar request in the forums.


    Hope this helps!
    Derek M.

  3. techmulla
    Posted 7 years ago #

    thankyou thankyou thankyou.

Topic Closed

This topic has been closed to new replies.

About this Topic