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.
This commit is contained in:
Kelly Dwan 2024-08-29 14:49:21 -04:00
parent 16bbfbd817
commit 906a87588c
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
3 changed files with 123 additions and 0 deletions

View file

@ -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;
}