From f530ad25968ad898978b54afb5733e259446b7f3 Mon Sep 17 00:00:00 2001 From: Damien Wilson Date: Thu, 31 Oct 2024 14:43:32 +0000 Subject: [PATCH] Update search result listing --- .../clarity/inc/content-filter/search.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/public/app/themes/clarity/inc/content-filter/search.php b/public/app/themes/clarity/inc/content-filter/search.php index 275145421..874cfd8c4 100644 --- a/public/app/themes/clarity/inc/content-filter/search.php +++ b/public/app/themes/clarity/inc/content-filter/search.php @@ -19,7 +19,6 @@ class Search { - /** * FilterSearch constructor. * @@ -51,7 +50,7 @@ public function hooks(): void * @return void */ - public function loadEventSearchResults() + public function loadEventSearchResults(): void { if (!wp_verify_nonce($_POST['_nonce'], 'search_filter_nonce')) { exit('Access not allowed.'); @@ -76,7 +75,7 @@ public function loadEventSearchResults() $events = $events_helper->get_events($agency_term_id, $filter_options) ?? []; - return wp_send_json([ + wp_send_json([ 'aggregates' => [ 'totalResults' => count($events), 'resultsPerPage' => -1, @@ -85,7 +84,7 @@ public function loadEventSearchResults() 'results' => [ 'templateName' => "c-events-item-list", 'posts' => array_map([$this, 'mapEventResult'], $events), - ], + ] ]); } @@ -143,12 +142,13 @@ public function mapPostResult(\WP_Post $post) $thumbnail = get_the_post_thumbnail_url($post->ID, 'user-thumb'); $thumbnail_alt = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true); - $author = $post->post_author; - $author_display_name = $author ? get_the_author_meta('display_name', $author) : ''; + $authors = new Authors(); + $authors = $authors->getAuthorInfo($post->ID); + $author = $authors[0] ?? false; + $author_display_name = $author['name'] ?? false; if (!$thumbnail) { - // Mutate thumbnail with author image. - $thumbnail = $author ? get_the_author_meta('thumbnail_avatar', $author) : false; + $thumbnail = $author['thumbnail_url'] ?? false; $thumbnail_alt = $author_display_name; } @@ -161,7 +161,7 @@ public function mapPostResult(\WP_Post $post) 'permalink' => get_permalink($post->ID), 'post_thumbnail' => $thumbnail, 'post_thumbnail_alt' => $thumbnail_alt, - 'author_display_name' => $author ? get_the_author_meta('display_name', $author) : '', + 'author_display_name' => $author_display_name, ]; }