Home › Forums › General Issues › Image field on term returning ID instead of Array › Reply To: Image field on term returning ID instead of Array
It’s extremely difficult to eliminate all the possibilities like in the original post.
For example, adding additional post type to a site would mean having additional problems in the future. Or returning posts that you don’t want from a post type you don’t really want for search results.
A better solution would be to make sure that you are currently querying a post type that can have ‘category’ as a term.
function alter_category_query($query) {
if(is_category() && empty($query->query_vars['suppress_filters'])
&& empty($query->query_vars['suppress_filters']) ||
$query->query_vars['suppress_filters'] == 'post') {
$query->set('post_type', array('course'));
return $query;
}
}
add_filter('pre_get_posts', 'alter_category_query');
The above will only make the change if you’re currently doing a query for posts and you won’t need to worry about future changes causing problems you’ll need to track down.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.