Related posts based on taxonomy
-
Hi,
I’m trying to display related posts based on custom taxonomy.
I created 4 custom taxonomies and I’m using them instead of regular tags. I want to display related articles based on 1 or more taxonomy but I can’t find any answers on how to do that.
This is the code that was displaying related articles based on tags. I can’t make it work for my custom tags.<?php // related entries based on tags $backup = $post; // backup the current object $tags = wp_get_post_tags( $post->ID ); $tagIDs = array(); if( $tags ) { $tagcount = count( $tags ); for( $i = 0; $i < $tagcount; $i++ ) { $tagIDs[ $i ] = $tags[ $i ]->term_id; } $args = array( 'tag__in' => $tagIDs, 'post__not_in' => array( $post->ID ), 'showposts' => 5, 'caller_get_posts' => 1 ); $my_query = new WP_Query( $args ); if( $my_query->have_posts() ) { ?>
Any idea?
Thanks.
Chris
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Related posts based on taxonomy’ is closed to new replies.