Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

ACF module with a term controller #101

Closed
thomascharbit opened this issue Sep 15, 2018 · 4 comments
Closed

ACF module with a term controller #101

thomascharbit opened this issue Sep 15, 2018 · 4 comments

Comments

@thomascharbit
Copy link

Using $acf = true on a term controller (for taxonomy term template like taxonomy-$taxonomy.blade.php) is returning the wrong fields for me.

It returns the loop first post fields instead of the actual term fields.
It works correctly if there is no posts in the loop (term with no linked posts).

I guess the issue comes from the use of ACF's get_fields() function, which needs more context to understand we are looking at a term and not a post type?

It looks like passing get_queried_object() as a second parameter fixes it, unsure if this is safe to do!

@darrenjacoby
Copy link
Member

darrenjacoby commented Sep 19, 2018

Hey @thomascharbit yea, that is very much a ACF issue, however, I think in this case it's worth providing more context. I'll test out a get_queried_object() approach for taxonomies.

@thomascharbit
Copy link
Author

thanks @darrenjacoby!

@darrenjacoby
Copy link
Member

I see no problem using get_queried_object() for ACF fields, so I've gone with that approach.

All results seem like what we want in this case, https://codex.wordpress.org/Function_Reference/get_queried_object

Included in next release.

@thomascharbit
Copy link
Author

Awesome, thanks again

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants