Forums › Forums › Search & Filter Pro › Output a Taxonomy field in results.php
- This topic has 4 replies, 2 voices, and was last updated 5 years, 7 months ago by
Anonymous.
-
Anonymous(Private) July 18, 2019 at 11:55 am #216565
Hi Trevor,
I’ve been modifying the Search and Filter Pro results.php file to output custom elements, mainly using custom fields too.
I have created a field in a custom Taxonomy “Hut Type” and am wondering if it is possible to output this in the results.php file?
So say I have filtered by a “Hut Type” and the page has reloaded with the query string in the URL, is there a way to get the results.php file to output the field located in that Hut Type if it has been filled in?
The Hut Type is a radio field too if this is any help.I look forward to hearing back from you, please let me know if you need any further clarification?
Thanks,
AlexTrevor(Private) July 18, 2019 at 2:42 pm #216585To get the terms for that post, you would use code like this:
$terms = wp_get_post_terms( get_the_ID(), 'hut_type');
You may then need to format or otherwise process $terms. It will be an array, by the way, even if there is only one term:
https://codex.wordpress.org/Function_Reference/wp_get_post_terms
Anonymous(Private) July 18, 2019 at 3:03 pm #216591Hi Trevor,
Sorry, I’m not sure I explained myself very well!
I’m not looking to output a field on an individual post, I am looking to output a field from a Hut Type (taxonomy item).
So I have 3 Hut Types at the moment (note, these are taxonomy items, not posts)…
Hut Type 1
Hut Type 2
Hut Type 3Each one has a custom field in it called “Banner Image”, as I need to display a different image per Hut Type.
If “Hut Type 1” was selected as the radio button in the Search and Filter area, I’d like only items with this Hut Type selected to load on the page, and also call the custom field located in the taxonomy item to output this banner…Is this possible?
I hope this makes sense!Thanks,
Alex -
AuthorPosts