Archived topic
Featured Image In Category Style Dispatch Theme
3 replies · Started by JOSE on January 13, 2021
I currently use the Dispatch theme.
How could I give the style to the posts header (featured image with the title) to the archives header?
I´d like to show a image with the category´s name.
Thanks
Hi there,
first off you would need this plugin so you can give Categories a featured Images:
https://wordpress.org/plugins/categories-images/
Then you would add this PHP Snippet to your site:
add_filter( 'generate_page_hero_background_image_url', function( $url ) {
if ( is_category() && function_exists( 'z_taxonomy_image_url' ) ) {
$image = z_taxonomy_image_url();
if ( $image ) {
return $image;
}
}
return $url;
} );
Then any Header Element you set to display on a Category Archive will use your new category featured images.
How could we make it with the new Template content?
Hi there,
considering that plugin is out of date - I would use ACF to add a Category Image to your Category terms.
This article explains how:
https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/
Then you can use set a Dynamic Background Image using the Term Meta option and simply add the Field Name added by ACF as your Meta Field Name.