Category Display Page

Home Forums Calendar Products Events Calendar PRO Category Display Page

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #47826
    jebs38
    Participant

    I am trying to make a custom template page that will display category calendar pages based on the code posted here:

    http://pastebin.com/XFZe5tvZ

    I took that and tried this:

    http://pastebin.com/FsqYmuPJ

    Can anyone help me clean up my code. I don’t know php and I am sure that I have formatted something incorrectly.

    I have read through this post: http://wordpress.org/support/topic/plugin-the-events-calendar-bringing-one-event-category-into-a-page?replies=26 and that thread is closed.

    John

    #47837
    Jonah
    Participant

    Hi John,

    First of all, don’t use query_posts, use WP_Query instead. Here’s a revised version of your code using WP_Query and some other things stripped out: http://snippi.com/s/x9flu9a – you’ll want to change the tax_query parameters to set which events category to display.

    I hope that helps! Let me know if you have any questions.

    #47846
    jebs38
    Participant

    Jonah,

    Thanks for getting back to me so quickly. I don’t understand where I put the category. And do I use the cat id number or the slug?

    #47868
    Jonah
    Participant

    Hi John,

    Where it says ‘featured’, just change featured to the slug of whatever the category name is you want to load events for. You can also change the operator to ‘NOT IN’ if you want to exclude the category and/or pass in an array of categories vs. just one by using: array( ‘featured’, ‘other-cat-slug’ ) instead of a singular category slug. The WP_Query reference contains lots of useful information on what you can do with this function: http://codex.wordpress.org/Class_Reference/WP_Query

    I hope that helps but let me know if you have any other questions.

    – Jonah

    #47875
    jebs38
    Participant

    Jonah, I got the category to show. Yeah!!! The problem is that it is now showing all events for that category from the past and way into the future.

    The other issue is that the events are being listed with no styling.

    Is there any way to get this to show a calendar grid or the upcoming events?

    John

    #47876
    jebs38
    Participant

    Jonah, I am already making progress in styling the listings. I do need some guidance in terms of displaying upcoming events or the next 10 events or something like that.

    #47914
    Jonah
    Participant

    Hi John,

    In order to get a calendar grid or list you would need to build all of that functionality yourself. A lot of the grid code is in /wp-content/plugins/the-events-calendar/views/gridview.php and /wp-content/plugins/the-events-calendar/views/table.php if you want to take a look at that.

    To get specific date ranges with WP_Query you need to pass in meta_query args like so:

    'post_type' => array(TribeEvents::POSTTYPE),
    'posts_per_page' => 10,
    'post_status' => 'publish',
    'meta_query' => array(
    'relation' => 'OR',
    array(
    'key' => '_EventStartDate',
    'value' => array(
    date('Y-m-d H:i:s', strtotime('now')),
    date('Y-m-d H:i:s', strtotime('+2 weeks'))),
    'compare' => 'BETWEEN',
    'type' => 'DATETIME'
    ),
    array(
    'key' => '_EventEndDate',
    'value' => array(
    date('Y-m-d H:i:s', strtotime('now')),
    date('Y-m-d H:i:s', strtotime('+2 weeks'))),
    'compare' => 'BETWEEN',
    'type' => 'DATETIME'
    )
    )

    Otherwise you could also use tribe_get_events() – our own query function for events that will let you pass in eventDisplay params like ‘all’, ‘past’, ‘upcoming’ and so forth to automatically affect the query. You can see more here: https://theeventscalendar.com/support/documentation/the-events-calendar-template-tags-general-functions/#functiontribe_get_events

    I hope that helps but let me know if you have any more questions.

    #47970
    jebs38
    Participant

    This reply is private.

    #47998
    jebs38
    Participant

    Jonah, I was able to get this working. Please keep this open for a little bit while I do some testing.

    #48069
    Jonah
    Participant

    Sounds good John, glad you got it working. I’ll keep the thread open for up to another week. Do let us know if you need more help with this.

    Thanks,
    Jonah

    #48254
    jebs38
    Participant

    Sounds good Jonah, I have got to create some custom CSS to style the output. I will let you know.

    #49528
    justjuicy
    Participant

    Hi Jonah.
    Thanks for the information above. This is just what I am looking for!
    I have tried both the code snippets – and successfully got them both to work with my theme. I am now trying to combine them.. but due to failing php skills I can’t seem to get it right.

    What i would like it to do is set up a page template to have a single event category displayed, and also have the date filtering code work alongside that (as above). The result would be a single category, with only future events from the next 2 weeks displayed.

    my template code with the date filtering is this:
    http://pastebin.com/c3zPnruT

    I’ve tried to slot in the tax_query parameter 100 different ways. but it seems to always show ALL categories.
    Thanks
    Steve (in Muscat, Oman)

    #49558
    Jonah
    Participant

    Hi Steve,

    Try this code for adding the tax_query:

    $args = array(
    'post_type' => array(TribeEvents::POSTTYPE),
    'posts_per_page' => 10,
    'post_status' => 'publish',
    'meta_query' => array(
    'relation' => 'OR',
    array(
    'key' => '_EventStartDate',
    'value' => array(
    date('Y-m-d H:i:s', strtotime('now')),
    date('Y-m-d H:i:s', strtotime('+16 weeks'))),
    'compare' => 'BETWEEN',
    'type' => 'DATETIME'
    ),
    array(
    'key' => '_EventEndDate',
    'value' => array(
    date('Y-m-d H:i:s', strtotime('now')),
    date('Y-m-d H:i:s', strtotime('+16 weeks'))),
    'compare' => 'BETWEEN',
    'type' => 'DATETIME'
    )
    ),
    'tax_query' => array(
    array(
    'taxonomy' => TribeEvents::TAXONOMY,
    'field' => 'slug',
    'terms' => array('2012'),
    'operator' => 'IN'
    )
    )
    );

    #49736
    Brian
    Participant

    I’m trying to get a grid view calendar showing in a custom page template to only show events from one category.

    Rather than having to grab all of the various pieces of code from the gridview file, would a template tag work?

    Is the plugin not set up to have parameters within the template tags….something like this:

    Anything we can use like that? not working for me currently

    #49737
    Brian
    Participant

    Sorry, here’s that code – http://pastebin.com/jha0HPGC

Viewing 15 posts - 1 through 15 (of 18 total)
  • The topic ‘Category Display Page’ is closed to new replies.