WordPress.org

Ready to get started?Download WordPress

Forums

Trying to have 3 rows with 3 ififferent categories in random order on homepage (1 post)

  1. aizas5544
    Member
    Posted 1 year ago #

    I'm trying to display a 3 random thumbnails from 3 different categories on my homepage like this

    Web design
    [] [] []
    Logo Design
    [] [] []
    Print Design
    [] [] []

    here's a link to my site: http://sickwebmedia.com

    here is my current code:

    <?php
          $args = array(
    
                       'post_type' => 'post',
                       'posts_per_page' => 9,
                       'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                       'orderby' => 'rand');
          query_posts($args);
          $x = 0;
          while (have_posts()) : the_post(); ?>
    
            <?php if($x == 0) { ?>
            <div class="featured_box first">
            <?php } elseif($x == 2) { ?>
            <div class="featured_box last">
            <?php } else { ?>
            <div class="featured_box">
            <?php } ?>
    
              <a>"class="img_hover_trans"><?php the_post_thumbnail('featured-small'); ?></a>
    	    </div>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Topic Closed

This topic has been closed to new replies.

About this Topic