WordPress.org

Ready to get started?Download WordPress

Forums

Hotscot Events
[resolved] Is there some documentation / how to I display events (4 posts)

  1. bendelaney
    Member
    Posted 1 year ago #

    Hi... I want to set up a home page with the excerpts of events shown, similar to the way blog posts can be shown... can you point me to the way to do this?

    thanks
    Ben

    http://wordpress.org/extend/plugins/hotscot-events/

  2. huntlyc
    Member
    Plugin Author

    Posted 1 year ago #

    Hi ben,

    I've pushed an update to the plugin that can show a table of events with a link to the individual event pages. The shortcode is [ht_list_events numevents=1] where num events is optional to limit the amount of events being shown.

    If you're comfortable with code and want to customize the output then then the following function may be of use to you:

    /**
     * getEvents - get events as object
     *
     * Will print a list of events either from the current date or one specified.  The end range can be specified or left blank to
     * show everything ending in the future.
     *
     * @param date start_date (yyyy-mm-dd) - Leave blank for today
     * @param date end_date (yyyy-mm-dd) [OPTIONAL]
     * @param limit - limit the number of posts
     * @return object of posts that relate to this query
     **/
    ht_getEvents($start_date = "", $end_date = "", $limit = 0)

    Here's an example of how to show the title with start and end dates in a h1 tag using the default wordpress date format with the event excerpt:

    <?php $events = ht_getEvents(); ?>
    <?php if($events): ?>
        <?php foreach($events as $event): ?>
            <h1><?php echo $event->post_title; ?>(<?php echo date(get_option('date_format', 'd/m/Y'), strtotime($event->sdte)) . ' - ' . date(get_option('date_format', 'd/m/Y'), strtotime($event->edte)); ?>)</h1>
            <?php echo apply_filters( 'the_content', $event->post_excerpt ); ?>
        <?php endforeach; ?>
    <?php else: ?>
        <p>No upcoming events.</p>
    <?php endif; ?>

    Hope this helps!!

    Cheers,
    Huntly

  3. bendelaney
    Member
    Posted 1 year ago #

    Very Slick!

    Thanks Very Much.

  4. huntlyc
    Member
    Plugin Author

    Posted 1 year ago #

    Your very welcome! I just wish that one day WordPress would notify me when someone starts a new forum topic on a plugins I contribute to!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic