Skip Navigation

[Closed] Setting filter for postdates

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.

Our next available supporter will start replying to tickets in about 2.28 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 17 replies, has 3 voices.

Last updated by Beda 6 years, 1 month ago.

Assigned support staff: Beda.

Author
Posts
#316238
Screen Shot 2015-07-10 at 08.53.01.png
Screen Shot 2015-07-10 at 08.52.49.png

I just want to use two filter in my View:
1) ProcesStatus which is handled via ShortCode
2) DateFilter via shortcode

The first one is working, but the second one is not working. See the attachment for the settings.

This is the query for the debug screen:

SELECT   wp_8_posts.* FROM wp_8_posts  INNER JOIN wp_8_postmeta ON ( wp_8_posts.ID = wp_8_postmeta.post_id ) WHERE 1=1  AND ( 
  MONTH( wp_8_posts.post_modified ) >= 2
) AND wp_8_posts.ID NOT IN (502) AND ( 
  ( wp_8_postmeta.meta_key = 'wpcf-proces-status' AND CAST(wp_8_postmeta.meta_value AS CHAR) = 'Done' )
) AND wp_8_posts.post_type = 'opdrachten' AND ((wp_8_posts.post_status = 'publish' OR wp_8_posts.post_status = 'private')) GROUP BY wp_8_posts.ID ORDER BY wp_8_posts.post_date DESC 

It looks like the query is selecting all dates with month >=2.

The strange thing is also that I cannot see the option to choose between "and" and "or" here.

What I want to do is to set a shortcode filter in addition to my shortcode filter for processtatus to set the amount of days/months/weeks for which I would like the see the results

Example" where processtatus="done" and modified-date not older then 30 days from now.

#316278

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello and thank you for contacting Toolset support.

1)
You should try to use 'equal to' parameter when you add your date filter. Please refer to the following link:
=> https://toolset.com/documentation/user-guides/filtering-views-query-by-date/
[ Refer to section: "You could even get posts that were published or modified the last month." ]

2)
If above does not help:

Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

#316302

When I use the 'Equal" to in combination with "past one" Month with value "2", I do get the entries from May 2015 - which is correct.

When I use "After or Equal" , I'm still getting older entries.

I would like to see just the entries from the last two months.

How can I arrange that?

#316602

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

1)
As I understand that you want past two months entries from todays date, correct?

2)
Could you please share a link where I can see your issue in action as well as what is the view name you are using?

3)
*** Please take FULL BACKUP of your database and your website.***
In order to investigate your issue if we require to check things on your install in order to see what could be going wrong there.

If you agree to this please use the form fields I have enabled below this comment box to provide temporary access details (wp-admin and FTP)?

I have set next reply as private.

#316696

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Unfortunately some CLEF plugin not allowed allow me to login inside your wp-admin panel. Could you please do needful on it and re-send me the access details.

#317015

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check you issue now, I have modified your view filter according to your requirement and its set to display past 2 months entries.

#317158

Minesh,

I have seen what you have done. Year = current_one and Past-month=2

Two remarks:
1) This will not work when it is Jan - because then you would like to see the entries from Jan and december last year
2) I would like to use a shortcode for either the year or the month to be able to get flexible filters in place - same way I have used the shortcode to filter the proces status.

The most important issue for me is to get a function in place that will filter the entries from the last months or weeks.

#317203

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Two remarks:
1) This will not work when it is Jan - because then you would like to see the entries from Jan and december last year
=> Ok, I understand this, you mean when we use past 2 months and current running month is Jan, so it should display records of jan and Dec last year but as we are using current year it will not be possible. I understand this and will look into this.

2) I would like to use a shortcode for either the year or the month to be able to get flexible filters in place - same way I have used the shortcode to filter the proces status.
=> You mean that you want to pass shortcode attribute with views for year or month.

Could you please confirm which attribute you want to pass using views. year or month? please send me one sample views shortcode with attribute you want to pass either year or month so we will proceed accordingly.

Also confirm, if you select attribute as year or month - what is the condition or effect.

#317271

The request is that I would like to use a variable (short code) to filter the entries depending on their "age" in terms of months.

All entries that are not older then XXXX months - where XXXX is the short code. For some views this would be 1, for another view 12, for another view 24 months.
But when it is Feb as example, I need to see the entries from Jan and Dec.

This filter may also be arranged with days or weeks or whatever. As long as I can define the time laps between now and the history period.

And in case this is not doable with a short code, I have to define various views.

Looking forward to your response.

#318205

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As I understand now:

1)
The request is that I would like to use a variable (short code) to filter the entries depending on their "age" in terms of months.

All entries that are not older then XXXX months - where XXXX is the short code. For some views this would be 1, for another view 12, for another view 24 months.
==> with following views shortcode you want to add one parameter "age" and you will pass the months.

[wpv-view name="Opdrachten WIP Monitor Toolset" processtatus="Done" age="4"]

So, if the current moth is March, it should show Mar, Feb, Jan, Dec entries accordingly from the todays date. Please confirm.

2)
This filter may also be arranged with days or weeks or whatever. As long as I can define the time laps between now and the history period.
==> When you say filter should be arranged with days or weeks, how you want to define it, how you will pass the days/weeks from views, as you are passing "age".

And in case this is not doable with a short code, I have to define various views.
==> You means you want multiple params?

#320417

Lets keep this simple and I want just to filter the entries based on the last 2 weeks.
I have adjusted this in the View "Opdrachten WIP Monitor Toolset" - which you can test on page /test-toolset/

Access details to the environment are still valid!

Select posts whose
Modified date is after or equal to: year:CURRENT_ONE(), week:PAST_ONE(2)
OR
Published date is after or equal to: year:CURRENT_ONE(), week:PAST_ONE(2)

But even with these parameters I do see much more then the entries from the last two weeks.

Please - help to get the filter in place to just show me the entries from the last two weeks here!

#321724

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please share wp-admin access details, its again not working at this end, I've also tried to take access details from your other tickets, unfortunately those are also not working.

#322293

Since Minesh currently has a few days off, I will replace him here in the forum.
I hope this is OK for you.

I can not login to your site, just the same as happened to Minesh.

You can see the result of the Login Process in my Screenshot.

I use the "username and password" option, which leads to the default WordPress Login Modal.

Please can you provide me some new access details?

Also I see this thread goes over different requests, and I see the last point would be to display with a View some Posts which are from the last 2 Weeks (edited or modified?)

To do so, you can set in the Query Filter this one (or similar, adapted to your needs)

Select posts whoseModified date is before: hour:CURRENT_ONE()
AND
Published date is after: week:PAST_ONE(2)

Please let me know if you have further questions regarding the issue mentioned in this Thread

Thank you for your patience.

#322586

Thanks for the Details

I was able to access now, thanks for adjusting the login workflow.

I changed the query filter slightly

I used:

Modified date is equal to: week:CURRENT_ONE()
OR
ORModified date is equal to: week:PAST_ONE(2)

Of course, above checks for Modified Posts Dates only, being in THIS Week, or 2 Weeks from now, countend towards the past.

If you also want to check for Published Dates, you shall add another similar filter, and set the comparison operator to OR (not AND, as AND will output only results that match BOTH criteria)

Now you get outputs of 2015 only, being modified in the last 2 weeks.

Is that matching your goal?

Please let me know if you have further questions regarding the issue mentioned in this Thread

Thank you for your patience.

#323958

Yes - This is indeed what I was looking for.

I have added your setting in the following way to my view "Opdrachten WIP Monitor last wks".

Select posts whose
Modified date is after or equal to: week:PAST_ONE(2)

This seems to be working also - I don't understand the reason to use the current or past_one(2).
When I was doing this for 4 weeks back - I was just getting the entries from this week and the one from 4 weeks ago. All entries in the middle were not selected!

Only wondering what the system will do when the year is changing ... I assume this will not affect this formula.

The topic ‘[Closed] Setting filter for postdates’ is closed to new replies.