Support » Theme: Attitude » posts in random order ONLY on homepage

  • Resolved zocimike



    This theme is realy great!
    I would like if the posts on the main page would be randomized on every load. I have done it with the code: query_posts('orderby=rand')

    …but there is a problem: all posts shown on every category and tag pages of my menu. I want it only in main loop. Is there any solution?

    if ( ! function_exists( 'attitude_theloop_for_archive' ) ) :
     * Fuction to show the archive loop content.
    function attitude_theloop_for_archive() {
    	global $post;
    	if( is_front_page() ) {
    		while( have_posts() ) {
    			do_action( 'attitude_before_post' );
    	<section id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<?php do_action( 'attitude_before_post_header' ); ?>
Viewing 1 replies (of 1 total)
  • finally I solved it:
    put this code before the WP loop in index.php
    <?php query_posts($query_string . '&orderby=rand') ?>

Viewing 1 replies (of 1 total)
  • The topic ‘posts in random order ONLY on homepage’ is closed to new replies.