Skip Navigation

[Résolu] Create a date separator in a view

This support ticket is created Il y a 7 années et 2 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par stuart Il y a 7 années et 2 mois.

Assisté par: Minesh.

Auteur
Publications
#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

Les langues: Anglais (English )

Fuseau horaire: 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