ThemeShaper Forums » Thematic

[closed]

Random Post Order?

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

    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.

    Thanks!

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

    Try :

    child_randomize_loop() {
    	query_posts('orderby=rand');
    }
    add_action('thematic_indexloop','child_randomize_loop');

    There are hooks for the other loops as well. Here is a visual guide to them: http://visualizing.thematic4you.com/

    Posted 3 years ago #
  3. brad1234
    Member

    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 3 years ago #
  4. brad1234
    Member

    Here's my current loop (I think)...how 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>
    			</div><!-- .post -->
    Posted 3 years ago #
  5. You want query_posts('orderby=rand'); before the while ( have_posts() ) : the_post() of your loop.

    Posted 3 years ago #
  6. brad1234
    Member

    Thank you!

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.