Help, wordpress post related content

first of all, English is not my native language

I want to see if anyone can help me

I’m using wordpress and Novavideo theme, and i need to show related content on my posts by a custom taxonomy that i made and not Categories as a default.

Here is my code (novavideo theme related content widget-function)

switch( $tv ){

   case 'related':

        global $post;

        $current_postID = $post->ID;
        $categories     = get_the_terms( $current_postID, 'sites' );

        if( $categories ){

            $id_cats = array_keys($categories);

            $args_query = array(
                'post_type'         => 'post',
                'posts_per_page'    => $nv,
                'orderby'           => 'name',
                'post__not_in'      => array( $current_postID ),
                'tax_query'         => array(
                                            'relation'          => 'AND',
                                            // cat
                                            array(
                                                'taxonomy' => 'sites',
                                                'field'    => 'id',
                                                'terms'    => $id_cats,
                                                'operator' => 'IN',
                                                )
                            )
            );

        }

and this

$home_query = new WP_Query($args_query);

if( $home_query->have_posts() ): ?>

    <?php if( $tv == 'related' ){
            global $post;
            $post_cat = wp_get_post_categories( $post->ID );
            }
    ?>

    <ul class="listing-<?php echo $ta;?> <?php if ($ta == 'carousel') { ?> carousel <?php } ?>">

        <?php while ( $home_query->have_posts() ) : $home_query->the_post();?>

            <?php 

                get_template_part( 'item', $ta );

            ?>

        <?php endwhile; ?>

        <?php if ( $tv == 'related' && $ta != 'carousel' ) : ?>

            <li class="all_videos border-radius-5">
                <a href="<?php echo get_bloginfo('url');?>/?cat=<?php echo $post_cat[0];?>"><?php _e('See All', novavideo_get_theme_name()); ?></a>
            </li>

        <?php elseif ( $ta != 'carousel' ) : ?>

            <li class="all_videos border-radius-5">
                <a href="<?php echo get_bloginfo('url');?>/?filtre=<?php echo $tv;?>&amp;cat=<?php echo $cv;?>"><?php _e('See All', novavideo_get_theme_name()); ?></a>
            </li>

        <?php endif; ?>

    </ul>   

    <div class="clear"></div>


<?php endif;    

echo $after_widget;

wp_reset_query();

}

my custom taxonomy (hierarchical like categories) is “Sites” so i made some changes in order to get related content for my posts, but i want to show a button “See all” and this button has to redirect to the url of that taxonomy.
What would be the solution? hope you understand my question 😀 if not, tell me

Read more here: Help, wordpress post related content

Leave a Reply

Your email address will not be published. Required fields are marked *