Jaymes
Jaymes

Reputation: 23

get metadata from wordpress custom taxonomy

I have a custom taxonomy that I am using on a custom post type. I have added a custom field to my taxonomy through Advance Custom Fields.

I need to call the meta data that is selected on my taxonomy.php page. I can call the id of the custom taxonomy with this code...

$term = get_cat_ID( single_cat_title('slug',false) );
echo $term

This returns the taxonomy id correctly, so now I just need to query the metadata of this specific id to find the value of field 'list_template'

help is appreciated

Upvotes: 1

Views: 5742

Answers (2)

Jaymes
Jaymes

Reputation: 23

I did. Here is the code I used.

$templateCategory = "patient_category_$catIdChild";
$template = get_field('list_template', $templateCategory );

patient_category is my custom taxonomy slug. So just use your slug in it's place.

$catIdChild is the custom taxonomy ID. So once you have your tax ID, you can plug that variable in to get query that specific taxonomy.

list_template is the slug of my custom field on my taxonomy page, so obviously replace it with your custom field slug.

Let me know if you need some help with it.

Upvotes: 0

Tunji
Tunji

Reputation: 187

You can use the get_post_meta function in wordpress to achieve this, that's a linkget_post_meta to it in the wordpress codex.

Upvotes: 0

Related Questions