From 906a87588c97e5578f632c136b492c67a3b0b81f Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Thu, 29 Aug 2024 14:49:21 -0400 Subject: [PATCH] Templates: Add archive template for pledge list This also uses the pledge list display for search results, which may need to be updated once case studies are full posts. Until then, the search results only returns pledges. --- themes/wporg-5ftf-2024/functions.php | 15 +++ .../patterns/archive-5ftf-pledge.php | 97 +++++++++++++++++++ .../templates/archive-5ftf_pledge.html | 11 +++ 3 files changed, 123 insertions(+) create mode 100644 themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php create mode 100644 themes/wporg-5ftf-2024/templates/archive-5ftf_pledge.html diff --git a/themes/wporg-5ftf-2024/functions.php b/themes/wporg-5ftf-2024/functions.php index 3add841..0b7b16f 100644 --- a/themes/wporg-5ftf-2024/functions.php +++ b/themes/wporg-5ftf-2024/functions.php @@ -18,6 +18,7 @@ require_once __DIR__ . '/src/pledge-teams/index.php'; */ add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' ); add_filter( 'the_content', __NAMESPACE__ . '\inject_pledge_content' ); +add_filter( 'search_template_hierarchy', __NAMESPACE__ . '\use_archive_template' ); /** * Enqueue scripts and styles. @@ -58,4 +59,18 @@ function inject_pledge_content( $content ) { $data = get_pledge_meta( get_the_ID() ); $content = apply_filters( 'the_content', $data['org-description'] ); return $content; + +/** + * Switch to the archive.html template on search results. + * + * @param string[] $templates A list of template candidates, in descending order of priority. + */ +function use_archive_template( $templates ) { + global $wp_query; + + if ( is_search() ) { + array_unshift( $templates, 'archive-5ftf_pledge.html' ); + } + + return $templates; } diff --git a/themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php b/themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php new file mode 100644 index 0000000..8329f03 --- /dev/null +++ b/themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php @@ -0,0 +1,97 @@ + + + +
+ +

+ + + +
+ +
+ +
+ +
+ +
+ + + +
+ + +
+ +
+ + + +
+ + + +
+ +
+ +
+ + + + +
+ +
+ +
+ + + +
+ +
+ + + +

Has pledged…

+ + + +
+ + + +

small avatar list

+ +
+ +
+ + + + + + + + + + + + + + +
+ diff --git a/themes/wporg-5ftf-2024/templates/archive-5ftf_pledge.html b/themes/wporg-5ftf-2024/templates/archive-5ftf_pledge.html new file mode 100644 index 0000000..ede382b --- /dev/null +++ b/themes/wporg-5ftf-2024/templates/archive-5ftf_pledge.html @@ -0,0 +1,11 @@ + + + +
+ + + +
+ + +