This is the front end where I submit parameters to the View.
<div class="container">
<div>
<h1 class="sub-ttl sub-ttl-r">
Search for Plants by their Medicinal Uses:
</h1>
<label class="label-right" for="wpv-complaint">Complaint Treated:</label>
[xyz-ips snippet="select-complaint"]
<label class="label-right" for="wpv-system-state">System / State Effected:</label>
<select name="wpv-system-state">
<option value="" disabled selected hidden>No System / State selected</option><br/>
[xyz-ihs snippet="select-options-system"]
</select>
<label class="label-right" for="wpv-actions">Herbal Action:</label>
<select name="wpv-actions">
<option value="" disabled selected hidden>No Herbal Actions selected</option><br/>
[xyz-ihs snippet="select-options-actions"]
</select>
<p style="font-size: 14px;">Select plants who's medicinal use includes (select an option):<br>
a) All the selected terms <input type="radio" name="all-any" value="All" checked><br>
b) Any of the selected terms <input type="radio" name="all-any" value="Any">
</p>
<div>
<button class="btn button" name="submit">Search</button>
<button class="btn butt"> Clear Search</button>
</div>
</div>
</div>
Can you please check if there's a problem here that's stopping the View running.
Thanks
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi David,
The the code below i've replaced the $_POST with $_GET because we can get the values from the URL. However please remember this is custom coding which is out of our support scope so my assistance here is limited. I would highly recommend hiring a developer to create this custom query for you.
//Return only posts from the current author when listing posts of type company:
add_filter( 'wpv_filter_query', 'prefix_show_only_current_author', 99,3);
function prefix_show_only_current_author( $query_args,$view_setting,$view_id ) {
if($view_id == 1111){
if(isset($_GET['submit'])) {
$relation = 'OR';
if($_GET['all-any'] == 'All') {
$relation = 'AND';
}
if( !empty( $_GET['wpv-system-state'] ) ||
!empty( $_GET['wpv-complaint']) ||
!empty( $_GET['wpv-actions'])) {
$query_args['tax_query'] = array(
'relation' => $relation,
array(
'taxonomy' => 'complaint-use',
'field' => 'slug',
'terms' => $_GET['wpv-complaint']
),
array(
'taxonomy' => 'system',
'field' => 'slug',
'terms' => $_GET['wpv-system-state']
),
array(
'taxonomy' => 'action-medicinal',
'field' => 'slug',
'terms' => $_GET['wpv-actions'],
)
);
}
return $query_args;
}
Please let me know if this helps.
Thanks,
Shane
Hi Shane, Thanks for this.
I'm making progress - beginning to see output.
The posts I'm searching are custom child posts, would like to also display their parent post title in the output. Is there shortcode for doing this?
Thanks
When I submit the search I redirect to a results page
<form action="?page_id=19218" method="get">
where I put the View shortcode:
[wpv-view name="medicinal use search"]
My issue is resolved now. Thank you!