• Resolved mrmender

    (@mrmender)


    Hi, I’m currently using the breaking news theme and I was wondering if someone could help me code the following so that the post will come up random:

    <div class="featuredtoppost">
    
                      <?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>
                      <?php if( get_post_meta($post->ID, "thumb", true) ): ?>
                      <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=<?php echo get_theme_mod('featured_top_left_thumb_height'); ?>&w=<?php echo get_theme_mod('featured_top_left_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
                      <?php else: ?>
                      <?php endif; ?>
    
                      <div class="clear"></div>
    
                      <span class="date"><?php the_time('F j, Y'); ?> – <a href="<?php the_permalink(); ?>#respond"><?php comments_number(__('Leave a Comment'), __('1 Comment'), __('% Comments'
    )); ?></a></span>
    
                      <div class="clear"></div>
    
                      <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent link to <?php the_permalink() ?>"><?php the_title(); ?></a></h3>
                      <?php the_excerpt(); ?>
                      <div class="clear"></div><br /><br />
                      <span class="readmore"><a href="<?php the_permalink() ?>" rel="bookmark"><?php _e("Read More", 'modthemes'); ?></a></span>
    
                      <br />
    
                      <?php endwhile; ?>
    
                  </div>

    I added query_posts(‘orderby=rand’); in several places and I can’t get it to work…

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • See what happens when you change:

    <?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')

    to:

    <?php $recent = new WP_Query("orderby=rand&cat=".get_theme_mod('featured_top_left')

    Thread Starter mrmender

    (@mrmender)

    That was it. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Orderby Rand Question’ is closed to new replies.