[Resolved] Featured image on Archive page

Home Forums Support [Resolved] Featured image on Archive page

Home Forums Support Featured image on Archive page

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1517840
    Samuel

    Hi,

    Is this possible to add a “uploadable featured image” option in archive edition page ?

    And then be able to call it with Element hook to display ii in an Archive page header ?

    Thanks for your help,
    Samuel

    #1517931
    Leo
    Staff
    Customer Support

    Hi there,

    Unfortunately not – WordPress ignores all metabox values on archive/posts pages so the featured image option won’t work.

    You will just need to use the Custom image option in the header element.

    #1517979
    Samuel

    Hi Leo,

    I will continue like if there was a solution to find here ok ? πŸ˜‰

    I looked a little bit more at this problem and I found some informations from Tom and David here in the forum.

    To add featured image option to an Archive there is a plugin called “Category Image”.

    This plugin offers a function to display the featured image :

    <?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(); ?>

    So it seems to be possible. πŸ˜‰

    Now I need help to use this function in a Header element.

    I need a hero style header and to display this image like a normal “featured image” would display. Or to be more specific like this : http://test.lesventsnousportent.com/sobre-nosotros/

    If I just call this image using a Hook like generate-header or other solutions I tried it’s displaying like this : http://test.lesventsnousportent.com/turismo/cultura/

    Could you help me find the proper solution here please ?

    Thanks a lot

    #1518236
    Tom
    Lead Developer
    Lead Developer
    #1518263
    Samuel

    Hi Tom,

    I tried this solution as well but it’s not working, can you validate my workflow

    I put the function in a Hook element wp_head, displaying on archive pages :

    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 I create a Header element with “featured image” ON and displaying on Archive Pages.

    But no image is displaying front-end.

    #1518272
    Elvin
    Staff
    Customer Support
    #1518286
    Samuel

    Thanks @Elvin, I followed this step by step without any result.

    #1518290
    Samuel

    Here is what I did

    Step 1
    Step 2
    Step 3
    Step 4
    Step 5
    Step 6
    Step 7

    #1518346
    Elvin
    Staff
    Customer Support

    Instead of adding the PHP snippets through a Hook Element, add the PHP snippets by following this guide: https://docs.generatepress.com/article/adding-php/

    We recommend using Code Snippets plugin if you don’t want to use a Child theme’s functions.php to add your snippets.

    #1518602
    Samuel

    Thanks Elvin, that was it !

    #1519660
    Elvin
    Staff
    Customer Support

    Thanks Elvin, that was it !

    No problem. πŸ™‚

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