• I’m trying to randomize the appearance of posts and their thumbnails on my homepage by adding orderby=rand in my category.php file. I’m using a child theme of Dessign’s Style theme. For some reason the orderby=rand array tag is not working and I don’t understand why.

    I’m developing locally so cannot post a link.

    Any help would be greatly appreciated. Thanks!

    Here is the relevant snippet of code:

    <?php
         global $post;
         $myposts = get_posts( 'orderby=rand&numberposts=7&category_name=Featured Small' );
         foreach($myposts as $post) :
           setup_postdata($post);
         ?>
    
          <div class="small_box">
          <h3 class="bottom_line_title"><a href="<?php the_permalink(); ?>"><?php echo substr(get_the_title(),0,20); ?><?php if(strlen(get_the_title() > 20)) { ?>..<?php } ?></a></h3>
          <?php
          if ( has_post_thumbnail() ) {
            ?> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('featured-small'); ?></a> <?php
          } else {
            ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo catch_that_image() ?>" /></a> <?php
          }
          ?>
          </div><!--//small_box-->
    
        <?php endforeach; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Randomize posts using globalpost’ is closed to new replies.