[Support request] Custom image header in a custom Taxonomy

Home Forums Support [Support request] Custom image header in a custom Taxonomy

Home Forums Support Custom image header in a custom Taxonomy

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #802116
    Dani

    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!

    #802549
    Tom
    Lead Developer
    Lead Developer

    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/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.