/    Sign up×
Community /Pin to ProfileBookmark

Display posts divided by date

I am using The Events Calendar plugin to display calendar events on a website. The trick is that the client wants the events that fall on the same day to be listed together. And, if possible, to only show the upcoming 2 months.

[B]For example,

Nov. 10, 2015

Accelerated payroll deductions

Nov. 15, 2015

Regular payroll deductions

Nov. 20, 2015

Canada Child Tax Benefit

Nov. 30, 2015

Corporate tax installments
Corporate tax returns
Universal Child Care Benefit[/B]

I was able to create a loop that shows my events, but they are all shown individually with the date for each:

<?php query_posts(array( ‘post_type’ => ‘tribe_events’ ) );
while (have_posts()) : the_post(); $url = esc_url( get_permalink( tribe_get_venue_id( $post->ID))); ?>
<h3><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></h3>
<p><?php echo tribe_get_start_date($post->ID, true, $format = ‘F j, Y – l’ );?><br>
<?php echo tribe_get_venue_link()?></p>

<?php endwhile;?>

[B]So it outputs:

Accelerated payroll deductions November 10, 2015 – Tuesday

Regular payroll deductions November 15, 2015 – Sunday

Canada Child Tax Benefit November 20, 2015 – Friday[/B]

And so on! Can somebody help me with this loop so I can show my events grouped by date, and possible have a function that shows automatically the next two months’ worth of events?

Thanks a bunch

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 13.2015 — I've done this sort of thing (in pseudo-code, just to give you the idea):
[code=php]
$date = '';
while($row = $result->fetch())
{
if($row['date'] != $date)
{
$date = $row['date'];
echo "<h3>$date</h3>n";
}
echo "<p>{$row['title']}</p>n";
}
[/code]
Copy linkTweet thisAlerts:
@ahmadabbasNov 14.2015 — sorry i am not working on php i am doing work on asp.net
Copy linkTweet thisAlerts:
@yanickdevauthorNov 17.2015 — Thanks Terry!
Copy linkTweet thisAlerts:
@yanickdevauthorNov 17.2015 — Thanks NogDog!
×

Success!

Help @yanickdev spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...