Skip Navigation

[Resolved] Grouping View Output by Month

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 3 replies, has 2 voices.

Last updated by zacharyL 1 year, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2516377
Screenshot 2022-12-15 at 11-02-10 2022 Board Member Resources Erie Water Works.png

Tell us what you are trying to do?
I'm trying to replicate the grouping of posts by month as seen in the screenshot attached.

But I'm trying to put Toolset Views spin on it, and make things more dynamic to make it easier for the client to add new posts as the year progresses, while also not requiring them to update the attribute values of multiple View shortcodes.

Is there any documentation that you are following?
I found this post of yours from 2013 that sorta addresses my needs (https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/), but there's a problem with the implementation. My current loop items are generic list items, wrapped in unordered lists. See as follows:

	[wpv-items-found]
	<ul>
	<!-- wpv-loop-start -->
		<wpv-loop>
          	<li><a href="[types field='document-attachment' output='raw'][/types]" target="_blank" aria-label="download [wpv-post-title] pdf">[wpv-post-title]</a></li>
		</wpv-loop>
	<!-- wpv-loop-end -->
	</ul>
	[/wpv-items-found]

I need the header outside of the unordered list so I can achieve an output that looks something like this:

<h3>December</h3>
<ul>
          	<li>Loop Item</li>
          	<li>Loop Item</li>
          	<li>Loop Item</li>
          	<li>Loop Item</li>
</ul>

<h3>November</h3>
<ul>
          	<li>Loop Item</li>
          	<li>Loop Item</li>
          	<li>Loop Item</li>
          	<li>Loop Item</li>
</ul>

[...]

While I suppose I could have multiple views on the page, I feel like this would make it cumbersome for the client to modify, as they will need to do this perpetually moving forward as their Board of Directors meet, when they need to post their meeting minutes, agendas, and whatever else.

Ideally, I'd like the client to copy the page that contains this view and just change out one shortcode attribute (the year) each year when they need to start up a new years worth of board meeting minutes.

What is the link to your site?
The page in question is hidden link

I'm going to be putting in separate views to give you an idea of what I'm trying to accomplish here, but know the page markup is going to look like this:

<h3>December</h3>
[wpv-view name="view-name" yearfilter="2022" monthfilter="12"]

<h3>November</h3>
[wpv-view name="view-name" yearfilter="2022" monthfilter="11"]

<h3>October</h3>
[wpv-view name="view-name" yearfilter="2022" monthfilter="10"]

Any help in this matter would be greatly appreciated. Thanks in advance!

#2516397
screenshot.jpg

Update, so I actually marked up my view in this manner, so that I could at least have something akin to what I'm trying to accomplish, without requiring a bunch of views to be in the page editor.

	<ul>
	<!-- wpv-loop-start -->
		<wpv-loop>
          	[heading condition="month" value="[wpv-post-date format='F']"]
          		<li class="resource-month-header"><h3>[wpv-post-date format='F']</h3></li>
          	[/heading]
          	<li><a href="[types field='document-attachment' output='raw'][/types]" class="resource reports" target="_blank" aria-label="download [wpv-post-title] pdf">[wpv-post-title]</a></li>
		</wpv-loop>
	<!-- wpv-loop-end -->
	</ul>

I suppose this will suffice as a solution for now, but I was still wondering if there was a way to go about this while having the headers outside of the lists.

#2516805

Minesh
Supporter

Languages: English (English )

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

No - there is no other better solution then you already have. That is why we shared the blog post so users can build the solution on their own.
- https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

#2517169

Ok, very good. Thank you for your time.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.