categories – How display related post only in Default category on single

Question

I have a website with lot of post. I use 3 or more category for my post. I wanna display post only for the “default category”.

I try this one but work with all category not only Default.
If you have any ideas ?

?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 &raquo;'); ?>
        </li>
    </ul>   
<?php }
wp_reset_postdata(); ?>

0
nicolaswecandoit 4 days 2021-11-24T17:48:54-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse