Rand order inst work ?
-
Hi, I’m trying of show a relationships posts, I use this code:
<?php $categorias = array(); $categories = get_the_category(); foreach($categories as $categoria){ array_push($categorias, $categoria->cat_ID); } ?> <div id="similares"> <h3 class="entry-title" style="margin: 20px 0 10px 0; width: 540px;">Relacionados</h3> <?php $args = array('showposts' => 3, 'orderby' => 'rand', 'category__and' => $categorias); print_r($args); $relac = new WP_Query($args); if($relac->have_posts()): while($relac->have_posts()): $relac->the_post(); ?> <div class="product-wrap"> <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php echo crop(get_the_title(),45,false); ?></a></h3> <div class="image"><a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php $imagenurlthum = get_thumbnail_src($post->ID); if(!empty($imagenurlthum)): ?><img height="115" src="<?php bloginfo('template_directory') ?>/timthumb.php?src=<?php echo $imagenurlthum; ?>&w=153" title="<?php the_title() ?>" alt="<?php the_title() ?>" /><?php else: ?><img height="115" src="<?php bloginfo('template_directory') ?>/timthumb.php?src=<?php bloginfo('template_directory') ?>/images/logo_login.gif&w=153" title="<?php the_title() ?>" alt="<?php the_title() ?>" style="margin: 25px 0 0" /><?php endif; ?></a></div> <div class="excerpt"><?php echo crop(strip_tags(get_the_excerpt()),80); ?></div> <div class="price"><?php echo get_post_meta($post->ID,'Precio',true) ?></div> </div> <?php endwhile; endif; ?>
If I use category parameters, will display a correct post, but never different posts, without variation !
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Rand order inst work ?’ is closed to new replies.