true, 'ignore_sticky_posts' => true, ); if( absint( $related_posts_section_post_no ) > 0 ) { $related_posts_query_args['posts_per_page'] = absint( $related_posts_section_post_no ); } else { $related_posts_query_args['posts_per_page'] = 4; } $current_object = get_queried_object(); if ( $current_object instanceof WP_Post ) { $current_id = $current_object->ID; if ( absint( $current_id ) > 0 ) { // Exclude current post. $related_posts_query_args['post__not_in'] = array( absint( $current_id ) ); // Include current posts categories. $categories = wp_get_post_categories( $current_id ); if ( ! empty( $categories ) ) { $related_posts_query_args['tax_query'] = array( array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $categories, 'operator' => 'IN', ) ); } } } $related_posts_query = new WP_Query( $related_posts_query_args ); if( $related_posts_query->have_posts() ) : $related_posts_section_title = get_theme_mod( 'alpha_blog_site_pages_post_single_related_posts_section_title', esc_html__( 'Related Posts', 'alpha-blog' ) ); $related_posts_section_display_post_meta = get_theme_mod( 'alpha_blog_site_pages_post_single_related_posts_section_display_post_meta', esc_html__( 'post_date', 'alpha-blog' ) ); ?>

have_posts() ) : $related_posts_query->the_post(); ?>
the_title_attribute( array( 'echo' => false ) ) ) ); ?>