• Resolved andyvu011992

    (@andyvu011992)


    MAE – Related Post only renders posts that have the same first tag as the current post. This does not always work as many people only use post categories. I would suggest extending it so it works with both tags and categories.

    if ( has_tag() ) {
                    $tags = wp_get_post_tags( get_the_ID() );
    
                    $args = array(
                        'post_type' => 'post',
                        'tag__in' => $tags,
                        'post__not_in' => array( get_the_ID() ),
                        'posts_per_page' => -1
                    );
                } else {
                    $cats = wp_get_post_categories( get_the_ID() );
                    $args = array(
                        'post_type' => 'post',
                        'category__in' => $cats,
                        'post__not_in' => array( get_the_ID() ),
                        'posts_per_page' => $settings['posts_per_page']
                    );
                }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Proposed changes to MAE – Related Post’ is closed to new replies.