From 37c61fbf07b7bd9dc50aae2b0f6e804ba29f83cd Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 15 Jun 2023 12:17:48 +0200 Subject: [PATCH] fix queries --- includes/collection/class-followers.php | 29 +++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/includes/collection/class-followers.php b/includes/collection/class-followers.php index 96d268b..601d129 100644 --- a/includes/collection/class-followers.php +++ b/includes/collection/class-followers.php @@ -431,25 +431,22 @@ class Followers { */ public static function get_outdated_followers( $number = 50, $older_than = 604800 ) { $args = array( - 'taxonomy' => self::POST_TYPE, - 'number' => $number, - 'meta_key' => 'updated_at', - 'orderby' => 'meta_value_num', - 'order' => 'DESC', - 'meta_query' => array( + 'post_type' => self::POST_TYPE, + 'posts_per_page' => $number, + 'orderby' => 'modified', + 'order' => 'DESC', + 'date_query' => array( array( - 'key' => 'updated_at', - 'value' => time() - $older_than, - 'type' => 'numeric', - 'compare' => '<=', + 'column' => 'post_modified_gmt', + 'before' => 604800, ), ), ); - $terms = new WP_Term_Query( $args ); + $posts = new WP_Query( $args ); $items = array(); - foreach ( $terms->get_terms() as $follower ) { + foreach ( $posts->get_posts() as $follower ) { $items[] = new Follower( $follower ); // phpcs:ignore } @@ -470,16 +467,16 @@ class Followers { 'posts_per_page' => $number, 'meta_query' => array( array( - 'key' => 'errors', - 'compare' => 'EXISTS', + 'key' => 'errors', + 'compare' => 'EXISTS', ), ), ); - $terms = new WP_Term_Query( $args ); + $posts = new WP_Query( $args ); $items = array(); - foreach ( $terms->get_terms() as $follower ) { + foreach ( $posts->get_posts() as $follower ) { $items[] = new Follower( $follower ); // phpcs:ignore }