Latest Post

How to Show related Posts For custom post Type in Wordpress

How to Show related Posts For custom post Type in Wordpress

How to Show related Posts For custom post Type in Wordpress


This code use for fetch Related Posts in your custom post Type

<?php

$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5,'post_type' => 'mjob_post', 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
<li>
<?php  the_post_thumbnail(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>

</li>

<?php }

wp_reset_postdata();

?>

No comments