Query inside post duplicated not working
-
Hello,
configure the plugin in a theme made by me, at the end of the post I made a query to show more post with related tags.
That query does not work in post duplicates.
This is my code:
$post_tag = get_the_tags ( $post->ID ); $id = get_the_id(); // Define an empty array $ids = array(); // Check if the post has any tags if ( $post_tag ) { foreach ( $post_tag as $tag ) { $ids[] = $tag->term_id; } } // Now pass the IDs to tag__in $relatedargs = array( 'showposts' => '5', 'post__not_in' => array($id), 'tag__in' => $ids, ); // Now proceed with the rest of your query $relatedposts = new WP_Query( $relatedargs ); while( $relatedposts->have_posts() ) : $relatedposts->the_post(); // the loop endwhile; wp_reset_postdata();
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Query inside post duplicated not working’ is closed to new replies.