Loopers & ACF - Getting a value from the Term Object

I have created a looper provider using “Dynamic Content”. The dynamic content calls my ACF field which is gsp_author. This is an ACF Taxonomy Field Type. The field type is set to return the Term Object.

Using {{dc:looper:debug_consumer}} I get the following object.

Index: 0
Current Data:
object(WP_Term)#25798 (10) {
[“term_id”]=>
int(15)
[“name”]=>
string(48) “Alternative Information & Development Centre”
[“slug”]=>
string(42) “alternative-information-development-centre”
[“term_group”]=>
int(0)
[“term_taxonomy_id”]=>
int(15)
[“taxonomy”]=>
string(14) “library_author”
[“description”]=>
string(0) “”
[“parent”]=>
int(0)
[“count”]=>
int(0)
[“filter”]=>
string(3) “raw”
}

How does one go about accessing one of the array keys from the object?

For a normal array we could access the key but I can’t seem to figure out how to access the key in the object.

Hey @urchindesign,

Thanks for reaching out!

To get the data from the object, you can use dynamic terms. For example, if you want to get the name, the dynamic code should be {{dc:term:name}}.

Hope that helps.

Thanks. Did my head in as I thought I had to use one of the “Looper” options.

On a side note is there a way, without creating a custom looper, to access a WordPress Object?

Hey @urchindesign,

There’s no other option to access the WordPress object, you need to use a Looper Provider.

Hope that helps.

In this instance I am using a looper provider using “Dynamic Content” as per the {{dc:looper:debug_consumer}} it is returning an Object.

If I wanted to access one of the items from the object how would I do that or how would I create another looper provider to access the object array?

Hey @urchindesign,

Based from the object in your first thread, you can access the name, slug, description, and etc by using this dynamic content.

Let say for name:

{{dc:term:name}}

For url:

{{dc:term:url}}

For description:

{{dc:term:description}}

Hope that helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.