Updated on October 24, 2020
In the past, I wrote a tutorial on how to set up category archive hero/header images using WP Term Images here.
This members-only tutorial provides the steps to do the same using Advanced Custom Fields.
- add a custom fields group having an image field set to appear on categories
- set images for the categories
- register a custom image size for the category header background image
- create a custom function that returns the URL of the category image field in the above size
- use this with Oxygen's dynamic data feature in the Template applies to category archives
Install and activate ACF.
Go to Custom Fields > Add New and add your field group.
Set the Return Format as Image Array.
Edit your categories and select/upload an image for each.
You need to regenerate the thumbnails if you are selecting images that were uploaded before implementing this tutorial.
Install and activate Code Snippets plugin.
Add a new Snippet named say, "Custom image sizes" having the following code:
add_image_size( 'category-image', 1600, 400, true );
Save changes and activate.
Add another Code Snippet.
Title: Get Category Image URL
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $599 one-time).
Already a member? Log in below or here.