Get related portfolio posts by tags in portfolio pages
-
I am using this code to get related posts.
<?php if ( is_single() ) { $tags = wp_get_post_terms(get_the_ID()); 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), 'posts_per_page' => 5, 'ignore_sticky_post' => 1 ); $relacionadas = new WP_Query ($args); if ($relacionadas->have_posts()) : ?> <div class="wrapper-related-posts"> <p><span class="prefix-widget-title"><i class="fa fa-chevron-right"></i></span> <?php _e('Related posts', 'ribosome'); ?></p> <div class="related-post"> <?php while ($relacionadas->have_posts()) : $relacionadas->the_post(); ?> '><?php the_title(); ?> <?php endwhile; ?> </div><!-- .recent-post --> </div><!-- .wrapper-related-posts --> <?php wp_reset_postdata(); ?> <?php endif; // if ($relacionadas->have_posts()) ?> <?php } //if ($tags) } //if ( is_single() ?>
But this code not showing related portfolio (jetpack-portfolio) posts in portfolio pages. How to get that?
- The topic ‘Get related portfolio posts by tags in portfolio pages’ is closed to new replies.