Edit code get post by custom taxonomy

by stevenchow1411   Last Updated August 28, 2019 11:08 AM

I have a code snippet showing related posts by category:

<div class="under-video-block">
<?php if ( is_active_sidebar( 'under_video' ) && is_single() ) :
    dynamic_sidebar( 'under_video' ); ?>
<?php else : ?>
    <?php //$nb_videos_related = get_theme_mod('wpsevst_nb_videos_related', '10');
    $related = get_posts( array(
        'category__in' => wp_get_post_categories($post->ID),
        'numberposts' => xbox_get_field_value( 'wpst-options', 'related-videos-number' ),
        'post__not_in' => array($post->ID)
        ) 
    ); ?>
    <?php if ($related) : ?>
        <h2 class="widget-title"><?php esc_html_e( 'Related videos', 'wpst' ); ?></h2>

        <div>
        <?php
            if( $related ) foreach( $related as $post ) {
                setup_postdata($post);
                get_template_part( 'template-parts/loop', 'video' );
            }
        ?>
        </div>
        <?php wp_reset_postdata();  

        $category = get_the_category($post->ID); ?>
        <div class="clear"></div>
        <div class="show-more-related">
            <a class="button large" href="<?php echo get_category_link($category[0]->term_id); ?>"><?php esc_html_e('Show more related videos', 'wpst'); ?></a>
        </div>
        <?php endif; ?>

<?php endif; ?>

I want to edit the above code to show a related post under a custom taxonomy called "director". What I have to do? I am an amateur who looks forward to helping. Thanks



Related Questions




Set terms in a custom post

Updated July 31, 2016 08:03 AM

Archive for custom taxonomy

Updated February 20, 2019 18:08 PM

WordPress Wallet/Credit without woocommerce

Updated July 22, 2019 12:08 PM