I have a custom post type called anime and a taxonomy called series. If I view any post and that post belongs term Banana it should list all the posts in term Banana in a dropdown list. Here's the code so far:
<?php
$category = get_terms( 'series' );
$catID = $category[0]->term_id;
$args = array(
'numberposts' => 5,
'category' => $catID,
'post_type' => 'anime'
);
$catPosts = get_posts( $args );
echo '<form method="POST">';
echo '<select name="goToPost" onchange="document.location=this.value">';
echo '<option value="">'.__('Relevent Posts', 'your_text_domain').'</option>';
foreach( $catPosts as $singlePost ) {
echo '<option value="'.get_bloginfo('url').'/index.php?p='.$singlePost->ID.'">'.$singlePost->post_title.'</option>';
};
echo '</select>';
echo '</form>';
?>
But it's not working right. it's basically listing all posts in the taxonomy and not within the term