Hi there,
On our home page, if you use this, the results are sent to a search results page.
This our home page: hidden link
Pic attached of search bar.
This the type of results visitors may get:
hidden link
Two things, is it possible to make the 'area' search filed, on the Home Page a required field?
And on the results page, is it possible to add in the view, a text field indicating the area searched, in this care Norfolk.
We have 12 areas, the idea, is if someone searches Norfolk, the results page shows a title Norfolk.
If Cornwall, the Cornwall title appears above the Filter Results on the search results page.
Thank you.
Hi Pete,
Thank you for contacting us and I'd be happy to assist.
To suggest the best way to achieve this, I'll need to see how this view is set up in the admin area.
Can you please share temporary admin login details, in reply to this message?
Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing these details.
I tried to access the admin area login page, but it is showing a 404 not found message.
It seems that website is using some hidden node for the admin area login page.
Can you please also share information about that?
Note: I've set your next reply as private again and no changes will be made on your website.
The admin access details worked, thank you.
To make the Area select field "required" you can include the following custom script in your view's "JS editor":
jQuery( document ).on( 'js_event_wpv_pagination_completed js_event_wpv_parametric_search_form_updated js_event_wpv_parametric_search_results_updated ready', function( event, data ) {
jQuery('select[name="wpv-area"]').attr('required', true);
jQuery('select[name="wpv-area"] option[value="0"]').val("");
});
The selected Area taxonomy's selected term's slug is available in the URL parameter "wpv-area". To get that term's title from that slug, you'll need a custom shortcode, as explained here:
https://toolset.com/forums/topic/split-advice-regarding-getting-the-taxonomy-term-title-and-description-dynamically/#post-1803221
Hi there,
Thank you for looking into this for me.
Ok so this shortcode: [get_term_data_custom parameter="wpv-stock-category" value="title" taxonomy="stock-category"]
Where does it go?
If I add to the Search & Pagination or Loop Editor it shows as code on frontend.
Thanks for writing back.
That custom shortcode's definition 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 active theme's "functions.php" file:
add_shortcode( 'get_term_data_custom', 'get_term_data_custom_func');
function get_term_data_custom_func($atts){
$parameter = $atts['parameter'];
$value = $atts['value'];
$taxonomy = $atts['taxonomy'];
if ( (!empty($parameter)) && (!empty($value)) && (!empty($taxonomy)) && (!empty($_GET[$parameter])) ) {
$category = get_term_by('slug', $_GET[$parameter], $taxonomy, 'ARRAY_A');
if($category) {
switch ($value) {
case 'title':
return $category['name'];
break;
case 'description':
return $category['description'];
break;
}
}
}
}
After that, you'll be able to use this new custom shortcode, like this:
[get_term_data_custom parameter="wpv-area" value="title" taxonomy="area"]
This will get the "area" taxonomy term's slug value from the URL parameter "wpv-area" and will return that term's "title".
Thanks for that info.
Certainly don;t wish to start adding things to the functions.php file.
So do I add this shortcode to the custom code feature in Toolset?
If I do, how to I make this work with the specific View in question?
Remember we have many and I only wish this to work with one.
Thank you.
> So do I add this shortcode to the custom code feature in Toolset?
- Yes, you can use the Toolset's custom code feature to register this custom shortcode, as explained here:
https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
Any custom shortcode that you'll register will be available to be used across the website. I'm afraid, it won't be possible to limit it only to a specific view.