Views plugin lets you build your own custom search for any content type. These searches can be based on post content, taxonomies and custom fields.
When you ask for help or report issues, make sure to tell us settings for your custom search.
Viewing 15 topics - 2,416 through 2,430 (of 2,476 total)
Problem: I have several checkbox custom fields that store a yes or no value. I would like to be able to type the label of any checkbox into a text search field and find results that have that checkbox checked.
Solution: Relevanssi can help filter posts, including associated custom fields and taxonomy terms, using a text search. Unfortunately checkboxes are not supported in text-based searches. You can get around this if your checkbox field values match their labels. For example, if your checkbox for "Robotic" has a value "robotic" - see the screenshot attached. Add the checkbox fields to your post content, using Types or Views shortcodes. Hide them with CSS if you do not want the values to appear in your post. Then Relevanssi can will index those field values and include them in text searches. Here's an example of the post body content including hidden field values:
Problem:
Custom searches initially display all results. How to change this so that it works like the Google homepage with no initial results until a search is made?
Solution:
There are two ways to do this. The simplest is to split the search form and search results onto separate pages (the search results page will still include the filters so that searches can be updated). When you insert a View using the Fields and Views button you are asked whether to display on the form or both, it should be fairly self-explanatory.
Otherwise you would need to add some custom code.
Try adding the following to your theme's functions.php file:
/**
* No initial results
*
* Don't show View results until a filter has been applied
*
* Tests for custom field filters, taxonomy filters, or text searches
*/
function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){
$target_views = array( 226 ); // Edit to add IDs of Views to add this to
if ( in_array( $view_id, $target_views ) ) {
// is there a filter set?
if ( !isset( $query_results->query['meta_query'] ) && !isset( $query_results->query['tax_query'] ) && !isset( $query_results->query['s'] ) ) {
$query_results->posts = array();
$query_results->post_count = 0;
}
}
return $query_results;
}
add_filter( 'wpv_filter_query_post_process', 'tssupp_no_initial_results', 10, 3 );
I have set up custom JavaScript to conditionally hide, show and set filter options and values based on the option selected in another filter. In the first time landing on the page, everything works as expected, however, when I refresh the page manually the filters fields behave as expected (visually) but the results don't reset.
Solution:
when you have done the fist step:
Select an option in the first filter and you'll see more filters appear and the search results change correctly
The URL of your browser will be changed with some URL parameters, so when you refresh the page, it will display the filtered results.
This is a feature of Views plugin, you can disable it by this:
Edit the view, in section "Custom Search Settings", enable option "Let me choose individual settings manually", enable option "Do not adjust URLs after loading search results", and test again.
My View in the front end does not work for no obvious reason. Parts are missing, the styles are off and the custom search is not working either. What could it be?
Solution
Make sure that you close your HTML tags.
You need to close all Row's DIV HTML for example, which might now only be opening, but never close in your code
Example:
<div class="row">
some more HTML
<div class="row">
some more HTML
Instead you should use the closing HTML too:
<div class="row">
some more HTML
</div>
<div class="row">
some more HTML
</div>
Not closing the HTML can exactly break the View as you experience. One single missing item may cause big effects.
What I need is if I choose two checkboxes from the same filter (see screenshot) I need that to be an OR search. Right now it's AND so it doesn't show results when I choose more than one at a time.
Solution:
Edit the view, in section "Query Filter". edit the filter from:
Course Type is a string equal to URL_PARAM(wpv-wpcf-course-type)
To:
Course Type is a string in URL_PARAM(wpv-wpcf-course-type)