This thread is resolved. Here is a description of the problem and solution.
Problem:
The customer asked how to show the view's results, ordered/grouped by year and month.
Solution:
Shared the steps and the custom code examples.
Relevant Documentation:
n/a
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Tell us what you are trying to do?
Grouping a What's on list by Year / Month
I am trying to group based on a custom field that holds a Unix timestamp.
I am struggling to get the function working, which I think is more to do with the conversion of the Unix timestamp
Thank you for contacting us and I'd be happy to assist.
The tutorial that you referenced, uses the post date field for the grouping, but the same steps can be used for the Toolset Types' date type custom field too.
1. The custom shortcode to conditionally show the year and month headings, will be the same:
//group by month and year
add_shortcode('heading', 'my_heading');
function my_heading($atts, $content = '') {
static $year = null;
static $month = null;
$condition = $atts['condition'];;
$value = $atts['value'];;
switch ($condition) {
case 'year':
case 'month':
if ($$condition != $value) {
$$condition = $value;
return $content;
}
break;
}
return '';
}
I think our problem lies in the fact that our custom field is storing the date as a Unix timestamp. We have a function in functions.php to convert it to formatted text, but when using this it still does not work.
Thanks for writing back and Toolset's Types date type field also stores the date, as Unix timestamp.
I've set the next reply as private, so that you can share the temporary admin login details of the development website, along with the link to the page with this view.
The code that you've entered was correct, but your new shortcodes "convert_datey" and "convert_datem" were not entered in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.
I added them and the conditional year and month headings started showing, as expected.
Structure-wise, you'll also need to change the view's grid structure, so that grid containers for each result are shown independently from the year and month headings.
For this, you'll need to remove the code for the headings from the "Fields and Text" block in the content template and insert it into the view's loop editor directly, so that it sits on top of each result item and not inside it.
The overall changes in the "Loop editor" section of the view will look like this:
Hi. Thanks for your help so far. I am glad I was on the right track.
Because we have this view as a grid layout, can you think of a way we can get the monthly banners to go across all three columns, rather than just the column when the month changes?