Related post by category in all post type
-
Hi everyones,
I want to create a related post by category but related in all post type. I have 2 post-types, the first (default post type) for artist that I manage, and a second for news/press release.
So I want to show related post by categories on single of default post type, but this related need to show post from second post type.
I tried this, but it doesn’t work with all post-type.
Any idea ?<?php $related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) ); if( $related ) foreach( $related as $post ) { setup_postdata($post); ?> <ul> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php the_content('Read the rest of this entry »'); ?> </li> </ul> <?php } wp_reset_postdata(); ?>
Thanks for your help, have a nice sunday !
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Related post by category in all post type’ is closed to new replies.