'post', 'post_status' => 'publish', 'posts_per_page' => bloghash_option( 'popular_post_number' ), // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page 'order' => $bloghash_popular_post_order[1], 'orderby' => $bloghash_popular_post_order[0], 'ignore_sticky_posts' => true, ); $tax_query = array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-quote' ), 'operator' => 'NOT IN', ), ); if ( ! empty( $bloghash_popular_post_categories && $bloghash_popular_post_data_source == 'category' ) ) { $tax_query[] = array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $bloghash_popular_post_categories, 'operator' => 'IN', ); } elseif ( ! empty( $bloghash_popular_post_posts && $bloghash_popular_post_data_source == 'post' ) ) { $bloghash_args['post__in'] = $bloghash_popular_post_posts; $bloghash_args['orderby'] = 'post__in'; // Override orderby to maintain the order of selected posts. $bloghash_args['posts_per_page'] = count( $bloghash_popular_post_posts ); // Set posts_per_page to the number of selected posts. } $bloghash_args['tax_query'] = $tax_query; $bloghash_args = apply_filters( 'bloghash_popular_post_query_args', $bloghash_args ); $bloghash_posts = new WP_Query( $bloghash_args ); // No posts found. if ( ! $bloghash_posts->have_posts() ) { return; } $bloghash_popular_post_elements = (array) bloghash_option( 'popular_post_elements' ); $bloghash_classes = bloghash_template_part_column_classes( $bloghash_args['posts_per_page'] ); while ( $bloghash_posts->have_posts() ) : $bloghash_posts->the_post(); // Post items HTML markup. ob_start(); ?>