Hi,
Thank you for contacting us and I'd be happy to assist.
The data from the resulting posts in a view, like the post fields, taxonomy terms, etc can only be accessed, within the loop ( i.e. inside the <wpv-loop>.....</wpv-loop> tags ).
Assuming, you're referring to the view "search by complaint", I've noticed that the searched taxonomy term's slug is passed in the URL of the search results page, for example:
/complaint-search/?wpv-system=ageing&wpv-action-medicinal=anti-asthmatic
You can register a custom shortcode, which can get that term slug value from the URL and then return that term's title.
For example:
add_shortcode( 'get_term_data_custom', 'get_term_data_custom_func');
function get_term_data_custom_func($atts){
$parameter = $atts['parameter'];
$taxonomy = $atts['taxonomy'];
if ( (!empty($parameter)) && (!empty($taxonomy)) && (!empty($_GET[$parameter])) ) {
$category = get_term_by('slug', $_GET[$parameter], $taxonomy, 'ARRAY_A');
if($category) {
return $category['name'];
}
}
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
This shortcode accepts 2 attributes:
- parameter: the URL parameter to get the term slug from
- taxonomy: slug of the taxonomy to which the term belongs
For example to show the "system" taxonomy's searched term:
[get_term_data_custom parameter="wpv-system" taxonomy="system"]
And to show the "action-medicinal" taxonomy's searched term:
[get_term_data_custom parameter="wpv-action-medicinal" taxonomy="action-medicinal"]
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar