ThemeShaper Forums » Thematic


Random Post Order?

(6 posts)
  • Started 8 years ago by brad1234
  • Latest reply from brad1234
  • This topic is not resolved
  1. brad1234

    I have a gallery theme using thematic, and I'm trying to completely randomize my post order every time someone comes to my site. I don't want the posts to be chronological or any other order that's set in stone...just completely random is perfect.

    After searching the wp forums, I understand that <?php query_posts('orderby=rand');?> can be used in the loop, but I'm a little stumped as to how I can make this change in thematic.


    Posted 8 years ago #
  2. You'd want to hook your code in before the loop.

    Try :

    child_randomize_loop() {

    There are hooks for the other loops as well. Here is a visual guide to them:

    Posted 8 years ago #
  3. brad1234

    Thanks em hr...I'm not too familiar with hooks...but if I just add the code you mentioned into the functions.php file, I should be good to go, correct?

    Posted 8 years ago #
  4. brad1234

    Here's my current loop (I think) would I go about making it random?

    function gallery_category_loop() {
      global $post;
      /* Count the number of posts so we can insert a widgetized area */ $count = 1;
      while ( have_posts() ) : the_post() ?>
    			<div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    				<div class="entry-content">
    				<?php childtheme_post_header() ?>
    	        	<a href="<?php echo the_permalink() ?>"><span class="slide-title"><?php echo the_title(); ?></span><img class="thumbnail" src="<?php if(get_post_meta($post->ID, 'thumbnail')){echo get_post_meta($post->ID, 'thumbnail', $single = true);} else{bloginfo('url'); echo "/wp-content/themes/gallery/images/thumbnail-default.jpg";} ?>" width="125" height="125" alt="<?php echo the_title() ?>" /></a>
    			</div><!-- .post -->
    Posted 8 years ago #
  5. You want query_posts('orderby=rand'); before the while ( have_posts() ) : the_post() of your loop.

    Posted 8 years ago #
  6. brad1234

    Thank you!

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.