Archived topic
Custom image header in a custom Taxonomy
1 reply · Started by Dani on February 5, 2019
Viewing posts 1–2 of 2
Hello!
I need to make a page-hero with a custom background image and a custom title. Both of them are Advanced Custom Fields. How could I make this???
Thank youuuu!
Hi there,
For the background image, we can do this:
add_filter( 'generate_page_hero_background_image_url', function( $url ) {
$background_image = get_post_meta( get_the_ID(), 'your_custom_field', true );
if ( $background_image ) {
$url = $background_image;
}
return $url;
} );
As for the title, I'm assuming you mean the {{post_title}} field?
If so, you can do this:
add_filter( 'generate_page_hero_post_title', function( $title ) {
$custom_title = get_post_meta( get_the_ID(), 'your_custom_field', true );
if ( $custom_title ) {
$title = $custom_title;
}
return $title;
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
This archived topic is closed to new replies.