I am trying to retrieve multiple custom taxonomy terms which I’ve configured in an ACF Taxonomy field in the theme settings. I’ve retrieved the content of the theme settings field. That means I have information like term_id, slug, etc.
But ACF doesn’t directly add the custom fields of the term itself, so I need Frontity to retrieve the term data, of course including the ACF fields.
This is an endpoint in my WordPress installation which works fine:
https://frontity.noesteprojecten.nl/wp-json/wp/v2/opdrachtgever?slug=ligarus,lumens
But when I try to use this endpoint in Frontity, I’m seeing the following error:
ServerError: post type from endpoints "posts,pages,media" with slug "opdrachtgever" not found
Frontity doesn’t seem to know that ‘opdrachtgever’ is a taxonomy, instead of a post-type, although I’ve added it to my frontity.settings.js file like this:
taxonomies: [
{
taxonomy: "opdrachtgever",
endpoint: "opdrachtgever",
postTypeEndpoint: "portfolio",
params: {
per_page: 20,
_embed: true,
},
},
]
This is my code in which I try to retrieve the configured terms. termSlugs
contains the slugs of the configured terms, separated with a comma. So like this: /opdrachtgever?slug=ligarus,lumens
if (termIDs.length > 0) {
const termLink = `/opdrachtgever?slug=${termSlugs}`;
useEffect(() => {
actions.source.fetch(termLink);
}, []);
dataTerm = state.source.get(termLink);
}
What do I need to do to make Frontity understand that it needs to retrieve the information of terms instead of a post-type?
Or does this approach actually not work and do I need to fetch every post separately? And if I would put this in a forEach
, wouldn’t that be way heavier then putting it in one fetch?