• Resolved superoreh

    (@superoreh)


    I now use this code in excperts on my homepage – it displays date ordered posts. How to get posts to display random? – Any idea?

    <?php
    	$post_class = 'odd';
    	$i = 50;
    ?>
    <div id="excerpts" class="section">
    
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    
    	<div class="post <?php echo $post_class; ?>">
    
    		<?php if($i == 1) : ?>
    			<h2 class="section-header"><?php _e('Recent Posts','options'); ?></h2>
    		<?php endif; ?>
    
    		<?php echo get_the_image_link(array('Thumbnail'),'thumbnail'); ?>
    
    		<h3>
    			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    		</h3>
    
    		<p class="byline">
    
    		</p>
    		<div class="post-meta-data">
    			<p>
    				<span class="categories"><?php _e('Vrsta: ','options'); ?> <?php the_category(', '); ?></span>
    				<br />
    				<span class="tags"><?php _e('','options'); ?> <?php the_tags('', ', ', ''); ?></span>
    			</p>
    		</div>
    
    	</div>
    
    	<?php
    		if('odd' == $post_class) $post_class = 'even';
    		else $post_class = 'odd';
    		$i++;
    	?>
    
    	<?php endwhile; ?>
    
    	<div class="navigation-links section">
    		<?php posts_nav_link('',
    			'<span class="previous">&laquo; '.__('Previous Page','options').'</span>',
    			'<span class="next">'.__('Next Page','options').' &raquo;</span>'
    		); ?>
    	</div>
    
    <?php else: ?>
    
    	<p><?php _e('Sorry, no posts matched your criteria.','options'); ?></p>
    
    <?php endif; wp_reset_query(); ?>
    
    </div>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to display random posts?’ is closed to new replies.