Home Forums General Issues Post featured image from category custom field image. Reply To: Post featured image from category custom field image.

  • All of this would be much easier if the plugin you mention has a filter that will allow you do substitute the category image for the post’s featured image, and this is what I’d look at before doing all of the updating that would be required to do it that way. I have never used this plugin, so, I cannot say if it’s possible to do or not. You should contact the plugin author and ask.

    To do this the hard way.

    Set 1:

    Create an acf/save_post filter

    In this filter check the category of the post, if it is in the category you want then get the post ID of the image save in the category and update the featured image value for the post.

    Getting values from terms is covered on this page

    Setting the featured image on a post is covered here

    Step 2:

    What happens when someone updates the image on the category?

    In this case you need an acf/save_post filter that will run when the category is updated. Let’s say that your photo category has an ID of 100. The your filter would check to see if the post ID that ACF passes is “term_100” and if it is then you need to get the image ID value, do a query to get all of the posts that are in that category and update the value of featured image value of every post.