MH Magazine please change related content from tag to same category
-
Hello sir,
please change related content from tag to same categoryif (!function_exists(‘mh_magazine_related_content’)) {
function mh_magazine_related_content() {
global $post;
$mh_magazine_options = mh_magazine_theme_options();
$tags = wp_get_post_tags($post->ID);
if ($mh_magazine_options[‘related_content’] === ‘enable’ && $tags) {
$tag_ids = array();
foreach($tags as $tag) $tag_ids[] = $tag->term_id;
$related = new wp_query(array(‘tag__in’ => $tag_ids, ‘post__not_in’ => array($post->ID), ‘posts_per_page’ => 3, ‘ignore_sticky_posts’ => 1, ‘orderby’ => ‘rand’));
if ($related->have_posts()) {
echo ‘<section class=”mh-related-content”>’ . “\n”;
echo ‘<h3 class=”mh-widget-title mh-related-content-title”>’ . “\n”;
echo ‘<span class=”mh-widget-title-inner”>’;
esc_html_e(‘Related Articles’, ‘mh-magazine’);
echo ‘</span>’;
echo ‘</h3>’ . “\n”;
echo ‘<div class=”mh-related-wrap mh-row clearfix”>’ . “\n”;
while ($related->have_posts()) : $related->the_post();
echo ‘<div class=”mh-col-1-3 mh-posts-grid-col clearfix”>’ . “\n”;
get_template_part(‘content’, ‘grid’);
echo ‘</div>’ . “\n”;
endwhile;
echo ‘</div>’ . “\n”;
echo ‘</section>’ . “\n”;
wp_reset_postdata();
}
}
}
}
add_action(‘mh_after_post_content’, ‘mh_magazine_related_content’);
- The topic ‘MH Magazine please change related content from tag to same category’ is closed to new replies.