Home Forums Front-end Issues Replace featured image with taxonomy image


Replace featured image with taxonomy image

  • Hello everyone,

    I use Custom Post Type UI plugin to create different post types, and ACF plugin to add additional fields. Im making posts for example movies, and having taxonomies like “drama”, “comedy”, “action” etc

    Now when I add new movie and select taxonomy, then on archive page I would like that featured image will be automatically that selected taxonomy image (image is added with ACF). So all drama movies will have one featured image, comedy movies another etc.

    is it possible?

  • You have 2 choices

    1) When the post is saved, using an acf/save_post filter Get the tax/term that the new post is saved to, get the image set for that tax/term, update the post thumbnail. I’m not going into much detail here because I would not do this. The main reason is that the image could change at any time and this will not retroactively update old posts if the image for the tax/term changes.

    2) Modify the templates where the featured image is shown and instead of showing this get and display the image for the term. This is what I would do. This can also be modified if you want to allow a different featured image as well as a default. Get the post thumbnail, if there is one then show it, if not then get the term image and show that.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Replace featured image with taxonomy image’ is closed to new replies.