Customising Month Based Archive Pages

Home Forums Calendar Products Events Calendar PRO Customising Month Based Archive Pages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #24611
    David
    Member

    So I have mini calendar setup in the sidebar so the ‘Current month’ (in between the Previous and Next Month buttons) links to a archive results page of specifically that month’s events. Well, in theory.
    The link successfully takes you to a URL such as /events/10-2012 (October’s results). However, it’s not quite there. (Admin team feel free to test it out with the URL supplied at this point)
    What’s Happening:
    Viewing a month-based page seems to use the table.php template – which in turn also doesn’t show that month’s results as it just shows ‘the current month’.
    I’m simply after a list-based loop of the results of that month. How can I do this?
    Is this something I can do via the plugin’s functionalities or can I bypass the plugin altogether and create this feature via a regular WP template and loop query? If so, how?
    As a bonus – and with the above working – I’d love to be able to have a title at the top page saying what Month is currently being viewed. Eg. ‘September, 2012’.

    Many thanks, in advance for your time.

    #24661
    Jonah
    Participant

    Hi David,

    I don’t think this is currently possible without some sort of custom code or hack and it’s more involved than I can afford to spend time on. You can certainly create your own custom loops wherever you want using tribe_get_events() or WP_Query but that’s going to be tricky tying into the links you’re building for the calendar widget (i.e. to automatically create the custom loops for each month link).

    You can also modify any of the event pages, including the list page by using pre_get_posts to affect the query and pass in start/end dates. The tricky thing with this is you’ll need to pass some sort of variable when someone clicks on the month in the calendar widget, and then detect what month was clicked on and convert that into your start/end date in the pre_get_posts function. I know, sounds messy but I can’t think of any other way.

    I hope that helps and points you in the right direction! Good luck!

    – Jonah

    #24722
    David
    Member

    Hi Jonah. I understand that it sits outside the scope of what the plugin offers and I’m already very close to achieving it. I’m just having a spot of trouble with querying a selected month’s posts, using tribe_get_events().

    Based from a previous script you made for someone else (found here https://gist.github.com/3148810) I have this script (below) that’s almost there in displaying a chosen month’s posts from clicking on a link in the mini-calendar. I’m tricking the day-based time query by predefining the start date at xxxx-xx-01 and the end date to xxxx-xx-31.

    My problem is the start date seems to be being ignored and seems to base itself off of today’s date instead of the one defined. If I set the start and end manually to the 12th of this month – I get that day’s event but also today’s and any others in between. I’d really appreciate your help on this. Is there a month based version of doing this?

    global $post;
    $getMonth = $_GET[‘viewMonth’];
    $CurrentDate = date(”. $getMonth .’-01′);
    $EndDate = date(”. $getMonth .’-31′);
    echo $CurrentDate;
    $events_today = tribe_get_events(
    array(
    ‘start_date’=>$CurrentDate,
    ‘end_date’=>$EndDate
    )
    );
    foreach($events_today as $post) {
    setup_postdata($post);
    etc.

    #24731
    Jonah
    Participant

    Hi David,

    Something might not be quite right with the above code you linked to. Try this instead: https://gist.github.com/3687846

    That should work for you. Let me know if not.

    Regards,
    Jonah

    #24734
    David
    Member

    Thanks Jonah, that sounds like it will be a winner (the strtotime(‘1 month’) is a great find).

    Unfortunately the Start Date still seems to insist on today’s date. I can alter end_date to see that it’s behaving but giving start_date something like ’22 Sep 2012′ still seems to include any events from today onwards. Could you perhaps test that script and tell me I’m not crazy? It is okay to set the dates in this format – perhaps I’m not doing it correctly?
    ‘start_date’ => ’22 Sep 2012′,
    ‘end_date’=> ’27 Sep 2012’,

    #24753
    Jonah
    Participant

    Hi David,

    Try passing in the eventDisplay arg with a value of ‘all’ like so:

    'eventDisplay' => 'all'

    That worked for me in getting the start date to affect the query.

    Cheers,
    Jonah

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Customising Month Based Archive Pages’ is closed to new replies.