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.
Minesh
Supporter
Languages:
English (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.
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
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