From 79031d05aa5783b58bdb6f059b7be11c0f0b6263 Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:19:08 +0100 Subject: [PATCH] Reset global $post and WP_Query after getting recent. --- deploy/config/init/fpm-start.sh | 2 +- .../clarity/src/components/c-article/view.php | 10 +++++-- .../src/components/c-last-updated/view.php | 28 ++++++++----------- .../src/components/c-news-article/view.php | 10 +++++-- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/deploy/config/init/fpm-start.sh b/deploy/config/init/fpm-start.sh index bf7753f16..9f6b3daf7 100644 --- a/deploy/config/init/fpm-start.sh +++ b/deploy/config/init/fpm-start.sh @@ -1,6 +1,6 @@ #!/bin/sh -if wp core is-installed 2>/dev/null; then +if wp core is-installed 2>/dev/null; then # WP is installed. wp sync-user-roles sync else diff --git a/public/app/themes/clarity/src/components/c-article/view.php b/public/app/themes/clarity/src/components/c-article/view.php index 6fbe8ddca..f4372d940 100644 --- a/public/app/themes/clarity/src/components/c-article/view.php +++ b/public/app/themes/clarity/src/components/c-article/view.php @@ -25,7 +25,10 @@ $query_args = new SearchQueryArgs((new Agency())->getCurrentAgency()['wp_tag_id'], 'post', 1, 5, true); // Run the query. -$query = new WP_Query($query_args->get()); +$recent_query = new WP_Query($query_args->get()); + +// Reset the post data. +wp_reset_postdata(); ?> @@ -44,9 +47,12 @@ diff --git a/public/app/themes/clarity/src/components/c-last-updated/view.php b/public/app/themes/clarity/src/components/c-last-updated/view.php index ca32414af..617c6abb6 100644 --- a/public/app/themes/clarity/src/components/c-last-updated/view.php +++ b/public/app/themes/clarity/src/components/c-last-updated/view.php @@ -1,26 +1,20 @@ $term->name, $terms) : null; ?>
- +

- + -

+

+ +

diff --git a/public/app/themes/clarity/src/components/c-news-article/view.php b/public/app/themes/clarity/src/components/c-news-article/view.php index 19156c083..125667583 100644 --- a/public/app/themes/clarity/src/components/c-news-article/view.php +++ b/public/app/themes/clarity/src/components/c-news-article/view.php @@ -15,7 +15,10 @@ $query_args = new SearchQueryArgs((new Agency())->getCurrentAgency()['wp_tag_id'], 'news', 1, 6, true); // Run the query. -$query = new WP_Query($query_args->get()); +$recent_query = new WP_Query($query_args->get()); + +// Reset the post data. +wp_reset_postdata(); ?> @@ -37,9 +40,12 @@ Recent news'; - foreach ($query->posts as $key => $post) { + $main_post = $post; + foreach ($recent_query->posts as $key => $post) { include locate_template('src/components/c-article-item/view-news-feed.php'); } + $post = $main_post; + unset($main_post); ?>