help with custom-taxonomy-related-posts-query
-
Hello,
I’m pulling out a thread closed almost 1 year ago.
https://www.ads-software.com/support/topic/custom-taxonomy-related-posts-query?replies=28
I’m trying to show related posts by a custom taxonomy. I adapted some of the codes published by the members and managed to make it work, apart from ‘orderby’ => ‘rand’.This is the code:
<?php global $post; $terms = get_the_terms( $post->ID , 'cliente', 'string'); $do_not_duplicate[] = $post->ID; if(!empty($terms)){ foreach ($terms as $term) { query_posts( array( 'cliente' => $term->slug, 'showposts' => 5, 'caller_get_posts' => 1, 'orderby' => 'rand', 'post__not_in' => $do_not_duplicate ) ); if(have_posts()){ while ( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?> <li class="articlecontextual"> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a> <?php the_ID(); ?>" <h2><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> </li> <?php endwhile; wp_reset_query(); } } } ?>
Please anyone can help me to understand what missing or wrong?
Thank you!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘help with custom-taxonomy-related-posts-query’ is closed to new replies.