hidden link
If you check this page, you can see that even if there is nothing entered into the "Enter Shipment Code" field, it still lists out the details of every post of that post type.
What I would want to see is NO results and just the message "You must enter a shipment code."
This was working previously but at some point a plugin update may have broken things.
This is a clone of the site for you to investigate. It's probably just a simple change to the Views query.
hidden link
Search and Pagination
[wpv-filter-start hide="false"]
[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' eq '' ) AND ( '[wpv-search-term param='wpv_filter_submit']' ne '' )"]
<strong class="input-missing">[wpml-string context="wpv-views"]You must enter a shipment code.[/wpml-string]</strong><br><br>
[/wpv-conditional]
[wpv-filter-controls]
<div class="form-group"><div class="search-shipments-box">[wpv-filter-search-box placeholder="[wpml-string context="wpv-views"]Enter Shipment Code[/wpml-string]" output="bootstrap"]</div></div>
[wpv-filter-submit class="my-button" name="[wpml-string context="wpv-views"]Get Current Shipping Status[/wpml-string]" output="bootstrap"]
<br>
[/wpv-filter-controls]
[wpv-filter-end]
Loop Editor
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop wrap="1" pad="true">
[wpv-item index=1]
<div class="row ">
<br><div class="col-sm-12">[wpv-post-body view_template="Loop item in Search for Shipping Code"]</div>
</div>
[wpv-item index=other]
<br><div class="col-sm-12">[wpv-post-body view_template="Loop item in Search for Shipping Code"]</div>
[wpv-item index=pad]
<br><div class="col-sm-12"></div>
[wpv-item index=pad-last]
<br><div class="col-sm-12"></div>
</div>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<br><strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
Hello,
I have tried the URL you mentioned above, after submit the search form, it pass wpv_post_search URL parameter to view.
I suggest you try these:
1) Modify your shortcodes as below:
...
[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' eq '' )"]
<strong class="input-missing">[wpml-string context="wpv-views"]You must enter a shipment code.[/wpml-string]</strong><br><br>
[/wpv-conditional]
...
2) Use the wpv_filter_query filter hook, for example, add below PHP codes into your theme file "functions.php":
add_filter( 'wpv_filter_query', function ( $query_args, $settings, $view_id ) {
if ( $view_id == 999 && !isset($_GET['wpv_post_search'])) {
$query_args['post__in'] = array(0);
}
return $query_args;
}, 10, 3);
Please replace 999 with your post view's ID
More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
Thanks. The reason for including the wpv_post_search in the URL parameter is because this search form is also used on the home page and I don't want the "You must enter a shipment code." message on that page (obviously).
In the end, the easy way to solve this was simply by adding a conditional statement around the View Loop.
[wpv-layout-start]
[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' ne '' )"]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop wrap="1" pad="true">
[wpv-item index=1]
<div class="row ">
<br><div class="col-sm-12">[wpv-post-body view_template="Loop item in Search for Shipping Code"]</div>
</div>
[wpv-item index=other]
<br><div class="col-sm-12">[wpv-post-body view_template="Loop item in Search for Shipping Code"]</div>
[wpv-item index=pad]
<br><div class="col-sm-12"></div>
[wpv-item index=pad-last]
<br><div class="col-sm-12"></div>
</div>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<br><strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[/wpv-conditional]
[wpv-layout-end]
You can close the ticket. Thanks for your support.