mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 18:05:45 +03:00
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:
parent
16bbfbd817
commit
906a87588c
3 changed files with 123 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue