Skip to content

Instantly share code, notes, and snippets.

@undfine
Created September 24, 2024 20:05
Show Gist options
  • Select an option

  • Save undfine/17de821d498723467ef296b685aed708 to your computer and use it in GitHub Desktop.

Select an option

Save undfine/17de821d498723467ef296b685aed708 to your computer and use it in GitHub Desktop.
Filters the output of the featured image for a custom post type, based on a taxonomy with a custom image field.
@undfine
Copy link
Author

undfine commented Sep 24, 2024

This is currently using an example post_type of "provider" with a taxonomy called "specialty." This Taxonomy has the custom field "specialty_icon" which returns the attachment ID. If no featured image is found for the current post, it tries to replace it with the image set for the top-level term in that taxonomy. Can also set a default (attachment ID) if no image is set as featured, or if there is no image in the post terms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment