• Resolved zocimike

    (@zocimike)


    Hi

    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;
    query_posts('orderby=rand');
    	if( is_front_page() ) {
    		while( have_posts() ) {
    			the_post();
    
    			do_action( 'attitude_before_post' );
    ?>
    	<section id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<article>
    
    			<?php do_action( 'attitude_before_post_header' ); ?>
Viewing 1 replies (of 1 total)
  • Thread Starter zocimike

    (@zocimike)

    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.