Skip Navigation

[Resolved] Filtering Views Query by Date ?

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 1 voice.

Last updated by kayser 2 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2792018

Hello
I have a taxonomy with the term “coup de coeur” for a monthly selection of children's books. I want to display the result of the “coup de coeur” and below the “coup de coeur” of previous months.

I have found
Filtering Views Query by Date but I can't get it to work.
Can you help me in this direction?
Thank you
Guy

#2792063

Christopher Amirian
Supporter

Languages: English (English )

Hi Guy,

Let me see if I understand correctly.

You want to have a view that lists the posts containing the "coup de coeur" taxonomy term.

But you want to limit the result by showing last month's results correct?

If so, please add the view with normal method to show the posts with the taxonomy term filter and add another filter for the date.

You can use PAST_MONTH for the point that you want:

https://toolset.com/documentation/legacy-features/views-plugin/date-filters/

Also you can learn more here:

https://toolset.com/documentation/legacy-features/views-plugin/filtering-views-query-by-date/

Thanks.

#2792221

Thank you, I tested your links for my problem but to be more precise I want the “favorites” of the current month and below that a list with the “favorites” of previous months grouped by month. Like a “favorites” archive
January 2025
1
2
3
December 2024
1
2
3
4
November 2024
1
2

Guy

#2792294

Christopher Amirian
Supporter

Languages: English (English )

Hi Guy,

That is not possible with the block views. You will need to enable the legacy views:

- Go to "Toolset > Settings > General".
- Find the "Editing experience" section.
- Check the "Show both the legacy and Blocks interface and let me choose which to use for each item I build" checkbox.
- Reload the browser page.
- Go to the newly added "Toolset > Views" menu.
- There you will be able to edit the views.

For more information:
https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

After that you need to use two views, one view will generate the first grouping with the term filtering you want and in the content template of that view you will add another view as a child that will have separate filtering in response to each item of the parent view.

But that will be a complicated setup.

#2792406

Hi Christopher
I did the first part but I'm having trouble with the second.
" add another view as a child that will have separate filtering in response to each item of the parent view."
Can you help me with this part ?
Guy

#2792418

Christopher Amirian
Supporter

Languages: English (English )

Hi Guy,

I will need to have more detailed information on what you have done till now and the details you want to achieve.

I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private.

Tell me where to check and exactly which data you want to extract so I can help.

Thanks.

#2793174

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Thank you for the login information. I am going to check and get back to you if I have questions. I might need to ask for a second opinion.

Thank yu for your patience.

#2793690

Minesh
Supporter

Languages: English (English )

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

Can you please check now:
- hidden link

I've adjusted your view's loop output as given under:
=> hidden link

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<div class="container wpv-loop js-wpv-loop">
	<wpv-loop wrap="3" pad="true">
		[wpv-item index=1]
       [heading condition="year" value="[wpv-post-date format='F Y']"]
             <div class="row"><h1>[wpv-post-date format='F Y']</h1></div>
        [/heading]
		<div class="row ">
			<div class="col-md-4">[wpv-post-body view_template="loop-item-in-noscoupsdecoeurmensuel"]</div>
		[wpv-item index=other]
			<div class="col-md-4">[wpv-post-body view_template="loop-item-in-noscoupsdecoeurmensuel"]</div>
		[wpv-item index=3]
			<div class="col-md-4">[wpv-post-body view_template="loop-item-in-noscoupsdecoeurmensuel"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-md-4"></div>
		[wpv-item index=pad-last]
			<div class="col-md-4"></div>
		</div>
	</wpv-loop>
	</div>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

And added the following code to "Custom Code" section offered by Toolset:
=> hidden link

add_shortcode('heading', 'my_heading');
  function my_heading($atts, $content = '') {
  static $year = null;
  static $month = null;
  static $monthyear = null;
  $condition = $atts['condition'];
  $value = $atts['value'];
  switch ($condition) {
    case 'year':
    case 'month':
    case 'monthyear':
      if ($$condition != $value) {
        $$condition = $value;
        return $content;
      }
      break;
  }
  return '';
}

More info:
- https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

#2793775

Minesh
Many thanks for responding to my request.
Guy