From 05dac2ee6ff3a8c12abb1b14c9f4648de12d96ef Mon Sep 17 00:00:00 2001 From: Lea Cohen Date: Mon, 12 Jul 2021 10:22:38 +0300 Subject: [PATCH] Update simple-custom-post-order.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add check for count($result) in order to avoid error "Trying to get property ‘cnt’ of non-object" --- simple-custom-post-order.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/simple-custom-post-order.php b/simple-custom-post-order.php index 6b3ebcf..9e3ba59 100644 --- a/simple-custom-post-order.php +++ b/simple-custom-post-order.php @@ -281,8 +281,10 @@ public function refresh() { INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) WHERE term_taxonomy.taxonomy = '" . $taxonomy . "' "); - if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max) - continue; + if (count($result) > 0) { + if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max) + continue; + } $results = $wpdb->get_results(" SELECT terms.term_id