Skip Navigation

[Resolved] Views Filters Don't Work

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 4 years, 10 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#592613

I am trying to:
We have several views that allow a user to filter the listed content based on dates and other variables. The date filtering doesn't work and the pagination is faulty. The pagination appears to work but after switching to the next page it reverts and deletes the search parameters.

Link to a page where the issue can be seen:
hidden link - doesn't work at all
hidden link - filter works but pagination is faulty

I expected to see:
When we attempt to filter by date range we don't get the expected results, despite the fact that it works on the live site, it just won't co-operate in development. Date range searches simply return a complete list of all items. On the live site, the date filtering works, but when you click through the pagination, the second page reverts to a non-filtered list and once again starts to display all entries.

#592716

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Dear Laura,

Q1) The date filtering doesn't work
I can login your website, please check the view:
hidden link
There isn't any date filter in it.
What kind of date filter do you need?
If it is based on post publish date, please check our document to setup the filters:
https://toolset.com/documentation/user-guides/filtering-views-query-by-date/
If it is based on a custom date field created with Types plugin, please check this document:
https://toolset.com/documentation/user-guides/date-filters/

Q2) filter works but pagination is faulty
I can see the problem you mentioned above in page:
hidden link
Both pages are using same view "Article Search", but as I mentioned above, there isn't any date filter in it.
Are you using custom codes to setup the date filters?
Can you copy the custom codes here?

#593495

We are using a custom filter for the date and both forms are the same, I am told they used to work but no longer do.

The date filter is supposed to apply a custom date field, not published dates.

We tried the same process multiple ways, including re-writing it using Views Date Filtering but regardless of what we do we can not get the the results to work.

Same for pagination.

The custom date fields for the filtering are:
name="wpcf_s" = Start Date
name="wpcf_e" = End Date

[wpv-filter-start hide="false"]
[wpv-filter-controls]

<div style="background-color: #eeeeee;" class="ar-type">
<table>
  <tr>
     <td class="classified"><div  class="classified-inline classified-left">Article Type</div><div  class="classified-inline">[wpv-control field="article-type" url_param="article-type" type="select" auto_fill="wpcf-article-type" auto_fill_sort="asc"]</div></td> 
  </tr>  
  <tr>
    <td class="classified"><div  class="classified-inline classified-left">Title</div><div  class="classified-inline">[wpv-filter-search-box]</div></td>
    <td class="classified"><div  class="classified-inline classified-left">Keywords</div><div  class="classified-inline">[wpv-control field="article-keywords" url_param="article-keywords"]</div></td>
   </tr>
  <tr>
     <td class="classified"><div  class="classified-inline classified-left">Date: From</div> 
        <div class="classified-inline"><input type="text" class="wpcf-form-textfield form-textfield textfield" style="" value="" name="wpcf_s" id="wpv_control_textfield_s"></div></td>
    <td class="classified"><div  class="classified-inline classified-left">To</div> 
        <div class="classified-inline"><input type="text" class="wpcf-form-textfield form-textfield textfield" style="" value="" name="wpcf_e" id="wpv_control_textfield_e" ></div></td>
  </tr>
  <tr>
  <td class="classified"><div  class="classified-inline classified-left">[wpv-filter-submit name="Search"]</div></td>
    <td class="classified"><div  class="classified-inline classified-left">[wpv-filter-reset type="button"]</div></td>
    
  </tr>
</table>  
</div>
[/wpv-filter-controls]
[wpv-filter-end]

View is supposed to make things easier but it's actually turning out to be quite the opposite. We could have written these queries into templates in a 15-20 minute window and instead we've invested days trying different methods to get this to work. And because of the way Types stores data, even the queries we'd normally use in templates, don't produce correct results.

#593764

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Please check the view "Article Search"
hidden link

section "Query Filter", there are 5 filters in it, but none of them is related with date filters, are you using custom PHP codes to setup the date field filters? Can you confirm it?
And I tried the FTP access you provided above, it does not work, I get this error:

Status:	Resolving address of devpiipesdrum.sftp.wpengine.com
Status:	Connecting to 104.196.1.242:21...
Error:	Connection timed out after 20 seconds of inactivity
Error:	Could not connect to server

As I mentioned above, if you need a filter on custom date field, please follow our document to setup it:
https://toolset.com/documentation/user-guides/date-filters/

And I checked the single "Article", but there isn't any custom date field created with Types plugin.

If you still need assistance for it, please point out the custom date field name, I can setup a demo in your website.

#594100

Can you please show me where in the article you linked to it allows a user to select the date for filtering?
https://toolset.com/documentation/user-guides/date-filters/

Or in this one:

https://toolset.com/documentation/user-guides/filtering-views-query-by-date/

We don't know what dates the users will want to filter, so we can't predetermine what they should be - this is the issue we're having. Did you look at the page?

There are date fields in the post-type for Events and the Articles are supposed to be filtered by publication dates (post dates).

I highlighted above what a previous developer did to make this 'sort of work' on the live site - it only half works there (pagination is faulty) and doesn't work at all on the new site, neither the date range filtering nor the pagination work.

Try accessing via WP-Admin and see if you can build the filter set-up in a way that works - we've tried numerous combinations and methods and continue to keep trying but everything fails to produce results. Your documentation is written with very specific use cases in mind and it's fragmented and hard to follow. As I indicated above, you continue to link to articles that don't address what we're actually trying to do.

We want a filter above the post list that will allow a user to filter posts based on keywords, author, article type and specify a date range (November 2, 2016 to December 31, 2016, as an example) and for that filter to then only display results that match the user input criteria.

#594264

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

It is different from your previous post:
https://toolset.com/forums/topic/views-filters-dont-work/#post-593495

The date filter is supposed to apply a custom date field, not published dates.

In your case, the date filter is based on the post published date, but Views do not support the "published date" filter in the custom search form, so it will need custom codes, since the FTP access you provided is not valid, I can not find the custom codes you are using, please try one of below:
1) Find and copy the custom codes to here
2) make sure the FTP access you provided above is valid
https://toolset.com/forums/topic/views-filters-dont-work/#post-592613

I need to test and debug it in my localhost, thanks