I'm working on an extra function to list different stuff,
My function looks like: "display all hotels for a specific city" -> hotels is as CPT and CITY as custom Tax. So for exemple, lets display all hotels in Paris.
function test($cpt,$taxonomy = 0) {
$args (...)
$query (...)
while {...}
}
So I go to query different custom posts types, with or without a taxonomy. Until here, everything is OK.
But is it possible to get some data from this $taxonomy (city/paris) without creating a new query? Like I want to get custom field called "area_singular" linked to the $taxonomy
passed in the function? The title of it, etc.?
P.S. The value of $taxonomy
is passed by
$term = get_queried_object();
test('custom_post',$term);
P.P.S. Actually i have an other function, where i pass this custom field, & title in the function like test('cpt',$term,$custom_field,$title);
but I'm sure there is a way to get the data without passing them by the function.
EDIT: With
$taxonomy->post_title
I can get the title,
so how can I get the custom field the same way?