From fde50094bb752ca8e0caa62bd075abbd78c5e9f3 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 20 Dec 2023 09:33:22 +0100 Subject: [PATCH] refining suggested publications query --- single-questions.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/single-questions.php b/single-questions.php index 4c46ca3..6d2659c 100644 --- a/single-questions.php +++ b/single-questions.php @@ -55,14 +55,18 @@ get_header(); $args = array( 'post_type' => 'brochures', 'posts_per_page' => 5, - 'orderby' => 'rand', 'post_status' => 'publish', - 'meta_query' => array( + 'orderby' => 'rand', + 'meta_key' => 'brochure_pdf', + 'meta_value' => false, + 'meta_compare' => '!=', + 'tax_query' => array( array( - 'key' => 'brochure_pdf', - 'compare' => 'EXISTS' + 'taxonomy' => 'thematiques', + 'field' => 'term_id', + 'terms' => $mainThematique->term_id, ) - ), + ) ); $suggestedPublications = new WP_Query($args); $pagePublicationsUrl = get_page_by_template('template-publications.php') ? get_permalink(get_page_by_template('template-publications.php')[0]->ID) : null;