* @copyright Copyright (c) 2021, AeonWP * @link https://aeonwp.com/aeonblog * @license http://www.gnu.org/licenses/gpl-2.0.html * */ /** * Display related posts from same category * * @since AeonMag 1.0.0 * * @param int $post_id * @return void * */ if (!function_exists('aeonmag_related_post')) : function aeonmag_related_post($post_id) { global $aeonmag_theme_options; $title = esc_html($aeonmag_theme_options['aeonmag-single-page-related-posts-title']); if (0 == $aeonmag_theme_options['aeonmag-single-page-related-posts']) { return; } $categories = get_the_category($post_id); if ($categories) { $category_ids = array(); $category = get_category($category_ids); $categories = get_the_category($post_id); foreach ($categories as $category) { $category_ids[] = $category->term_id; } $count = $category->category_count; if ($count > 1) { ?>

$category_ids, 'post__not_in' => array($post_id), 'post_type' => 'post', 'posts_per_page' => 2, 'post_status' => 'publish', 'ignore_sticky_posts' => true ); $aeonmag_featured_query = new WP_Query($aeonmag_cat_post_args); while ($aeonmag_featured_query->have_posts()) : $aeonmag_featured_query->the_post(); ?>