Thêm bài viết liên quan slider flatsome wordpress

huong dan da ngon ngu shipping title trong wordpress

Hướng dẫn Thêm bài viết liên quan slider flatsome wordpress

function blog_posts_relation(){
    if(!is_single()) return;
    global $post;
    $categories = get_the_category($post->ID);
    $category_ids = array();
    foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;

    $args = array(
        'category__in' => $category_ids,
        'post__not_in' => array(get_the_ID()),
        'posts_per_page' => 10, // So bai viet dc hien thi
    );
    $my_query = new wp_query($args);
    $ids = array();
    if( $my_query->have_posts() ):
        while ( $my_query->have_posts() ) : $my_query->the_post();
            $ids[] = get_the_ID();
        endwhile; // end of the loop.
    endif; 
    wp_reset_query();
    echo '<div class="post-relation-block container">';
    echo '<div class="post-relation-block-head"><span>Tin liên quan khác</span></div>';
    echo do_shortcode('
  
    
'); echo '</div>'; } add_action('flatsome_after_blog', 'blog_posts_relation' );