I try to figure out this index-page (on a WordPress-site where the post-images should be shown in random order - but they are shown in reverse alphabetic order
Can anyone help to make “random” work?
This is index.php
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*/
get_header(); ?>
<div id="primary">
<div id="content">
<?php
$args = array(
'category_name' => 'featured small, color',
'post_type' => 'post',
'posts_per_page' => 45,
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
'orderby' => 'title',
'order' => 'RANDOM',
);
query_posts($args);
$x = 0;
while (have_posts()) : the_post(); ?>
<?php if($x == 0) { ?>
<div class="featured_box firsto">
<?php } elseif($x == 7) { ?>
<div class="featured_box lasto">
<?php } else { ?>
<div class="featured_box">
<?php } ?>
<?php if ( in_category( 'color' )) { ?>
<div class="featured_color <?php echo get_post_meta($post->ID, 'class', true); ?>">
</div>
<?php } ?>
<?php if ( in_category( 'featured-small' )) { ?>
<a href="<?php the_permalink(); ?>"class="img_hover_trans"><div class="gridimg"><?php the_post_thumbnail('featured-small'); ?></div></a>
<a href="<?php the_permalink(); ?>"class="title_hover_trans"><div class="gridtitle"><h3><?php the_title(); ?></h3></div></a>
<?php } ?>
</div><!--//featured_box-->
<?php if($x == 7) { $x=-1; ?>
<div class="clear"></div>
<div class="post_divider"></div>
<?php } ?>
<?php $x++; ?>
<?php endwhile; ?>
<div class="clear"></div>
<div class="frontspacer"></div>
<div class="nav_container">
<div class="left"><?php previous_posts_link('\\\ Previous') ?></div>
<div class="right"><?php next_posts_link('Next //') ?></div>
<?php wp_reset_query(); ?>
<div class="clear"></div>
</div>
</div><!--//content-->
</div><!-- #primary -->
<?php get_footer(); ?>
//Lars, Copenhagen