• May 3, 2012

    “how I get them to show up the images that are above the main content area in random order”

    In my header above the main content area
    I wanted to show off some images from my Photography category in a random order.
    Show I added this code to get the job done.

    <?php $my_query = new WP_Query('cat=8&showposts=3&orderby=rand');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    <!--CUSTOM LOOP STUFF HERE -->
    <?php endwhile; ?>

    So the key to getting this to work is: cat=8&showposts=3&orderby=rand

    Cat=8 is my Photography category. You can also use category_name=photography.

    show more than one category
    add more category numbers like so.
    Cat=8,12,1 and so on.

    showposts=3 is the number of posts you want to show.

    orderby=rand is the random order.

    You also can use: orderby=
    author, date, category, id, title, modified, parent and rand.

    Nothing new here but works good for what I need. Hope that help ya Tim.



เวอไนน์ไอคอร์ส

ประหยัดเวลากว่า 100 เท่า!






เวอไนน์เว็บไซต์⚡️
สร้างเว็บไซต์ ดูแลเว็บไซต์

Categories


Uncategorized