Skip Navigation

[Gelöst] Create a date separator in a view

This support ticket is created vor 6 Jahre, 7 Monate. 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.

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.

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 Antworten, has 2 Stimmen.

Last updated by stuart vor 6 Jahre, 7 Monate.

Assisted by: Minesh.

Author
Artikel
#566290

Tell us what you are trying to do?

I would like to display a list of 'classified ads' and have a data separator between the days ...

Rather than having a date next to each individual ad - possible?

e.g

---- Monday 4th September ----

Advert XYZ-83838289- bla bla bla
Advert XYZ-83838288- bla bla bla
Advert XYZ-83838287- bla bla bla

---- Sunday 3rd September ----

Advert XYZ-83838286- bla bla bla
Advert XYZ-83838285- bla bla bla
Advert XYZ-83838284- bla bla bla

---- Saturday 2nd September ----

Advert XYZ-83838283- bla bla bla
Advert XYZ-83838282- bla bla bla
Advert XYZ-83838281- bla bla bla

I am sure this is easy... but can't work it out 🙂

Thanks guys.

#566295

Minesh
Supporter

Languages: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Well - you can refer to the following Doc which may help you to build view which displays the posts group by date.
=> https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

However, you may need little customization and adjust the output according to your requirement.

#566592

Thanks for that one Minech - helped alot and I have resolved it.

Here is the amended solution for any who are interested in it.

I added this to the functions.php (in a child theme) - i added the day and the date to the listings.

//group by Year, Month, Day and Date.
add_shortcode('heading', 'my_heading');

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

And then added this to the top of the template for the view I wanted it displayed on

<h4>[heading condition="year" value="[wpv-post-date format="Y"]"] [wpv-post-date format="Y"] [/heading]</h4>

<h4>[heading condition="day" value="[wpv-post-date format="l"]"] [wpv-post-date format="l"][/heading] [heading condition="date" value="[wpv-post-date format="jS"]"][wpv-post-date format="jS"][/heading] [heading condition="month" value="[wpv-post-date format="F"]"][wpv-post-date format="F"][/heading]</h4>

And this gave me the result I wanted:

2017
Thursday 31st August

Title One
Title Two
Title Three

Monday 4th September

Title Four
Title Five

#570210
pers.jpg

Hey guys - I came across another issue here.

I would like to change the background colour of the div that the date is contained in, but the output still create the div elements between the posts,see image

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