Support » Plugin: Unique Headers » Wrong custom header for category archive

  • Resolved Benoit Chantre


    Hello Ryan,

    Thank you for this plugin!

    I have noticed a small bug with the category archive (and probably other archive pages).

    What’s expected: the custom header image id should be either the default header image when no custom header is set or the custom header image when it is set.

    What happens: the header image is the one from the first post of the category archive.

    Let me know if you need more infos.
    Thanks in advance for the fix 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ryan Hellyer


    Good spotting! I’ve set aside some time this weekend to look into this and another couple of bugs which I’d missed recently.

    Plugin Author Ryan Hellyer


    I looked into this just now, but I can’t replicate the issue. On my test site, the category archive always showed the primary header image when none is set for that category, not the first post in that category.

    Thank you for having checked that. I finally found the error comes from the theme.

    I finally think having found the source of the error: my theme uses the attachment_id to get the image url which is then used as a background image. The issue is that the attachment_id value doesn’t match the custom header image id. url and thumbnail_url values are good.

    Twenty Seventeen uses the header_image function which uses the url.

    In class-unique-headers-taxonomy-header-images.php, line 365, the $attachment_id is retrieved from the $post_id instead of the term id.

    Plugin Author Ryan Hellyer


    I’m confused. Do you think this is something which should be fixed in the plugin?

    Yes, it looks like a bug from the plugin.

    In class-unique-headers-taxonomy-header-images.php, line 361: the ID is retrieved by get_the_ID() instead of get_queried_object()->term_id.

    Then, line 365, Custom_Image_Meta_Box::get_attachment_id is used, but it uses get_post_meta() which doesn’t work in the context of a term. get_term_meta() should be used in this context.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Wrong custom header for category archive’ is closed to new replies.