Kriuchko
1/8/2019 - 2:49 PM

Plugin The Events Calendar the events calendar

Wordpress The Events Calendar

http://jamescollings.co.uk/blog/custom-wordpress-queries-extending-the-events-calendar-plugin/

$query = new WP_Query( array( 'post_type' => 'tribe_events',
	'meta_query' => array(
		array(
			'key' => '_EventStartDate',
			'value' => date('Y-m-d', strtotime('+1 week')),
			'compare' => 'date'
		)
	)
) );

https://theeventscalendar.com/knowledgebase/using-tribe_get_events/

—— проверка на сингл ивента

is_singular( 'tribe_events' )

—— пример кастомного превью ивента

<section class="events-card __line --dark">

  <?php
    $event_start_date = strtotime( get_post_meta( get_the_ID(), '_EventStartDate', true ) );
    $event_end_date = strtotime( get_post_meta( get_the_ID(), '_EventEndDate', true ) );
  ?>
  <p class="meta">
    <time datetime="<?php echo date( 'Y-m-d', $event_start_date ); ?>">

      <?php if( date( 'Ym', $event_start_date ) < date( 'Ym', $event_end_date ) ): ?>

        <?php echo date( 'j', $event_start_date ); ?> <?php echo date( 'F Y', $event_start_date ); ?>-<?php echo date( 'j', $event_end_date ); ?> <?php echo date( 'F Y', $event_end_date ); ?>

      <?php else: ?>

        <?php if( date( 'd', $event_start_date ) !== date( 'd', $event_end_date ) ): ?>
          <?php echo date( 'j', $event_start_date ); ?>-<?php echo date( 'j', $event_end_date ); ?>
        <?php else: ?>
          <?php echo date( 'jS', $event_start_date ); ?>
        <?php endif; ?>
        <?php echo date( 'F Y', $event_end_date ); ?>
      <?php endif; ?>

    </time>
  </p>

  <h3 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

  <?php if( $location_or_some_text = get_field( 'location_or_some_text' ) ): ?>
    <address class="location"><?php echo $location_or_some_text; ?></address>
  <?php endif; ?>

  <?php if( tribe_event_is_all_day( get_the_ID() ) ): ?>
    <p class="time"><?php _e( 'All Day', 'edhec' ); ?></p>
  <?php else: ?>
    <p class="time"><?php echo date( 'g.ia', $event_start_date ); ?> - <?php echo date( 'g.ia', $event_end_date ); ?></p>
  <?php endif; ?>

  <a href="<?php the_permalink(); ?>" class="btn btn-primary" title="Find out more"><?php _e( 'Find out more', 'edhec' ); ?><i class="icon-plus"></i></a>

  <?php if( $additional_scripts = get_field( 'additional_scripts', 'option' ) ): ?>
    <ul class="social-list">
        <li class="twitter"><span class="st_twitter_custom btn btn-share __dark icon-twitter"><span class="hidden-el">Tweet</span></span></li>
        <li class="linkedin"><span class="st_linkedin_custom btn btn-share __dark icon-linkedin"><span class="hidden-el">LinkedIn</span></span></li>
    </ul>
  <?php endif; ?>

</section>

——— dates

$event_start_date = strtotime( get_post_meta( get_the_ID(), '_EventStartDate', true ) );
					    $event_end_date = strtotime( get_post_meta( get_the_ID(), '_EventEndDate', true ) );
					    $current_event_month = date( 'F' , $event_start_date );
<?php if( tribe_event_is_all_day( get_the_ID() ) ): ?>

  <?php if( date( 'Ymd', $event_start_date ) !== date( 'Ymd', $event_end_date ) ): ?>

				                	<time class="date-of-events" datetime="<?php echo date( 'Y-m-d h:i', $event_start_date ); ?>"><?php echo date( 'l ga', $event_start_date ); ?>-<?php echo date( 'l ga', $event_end_date ); ?></time>

								<?php else: ?>

									<time class="date-of-events" datetime="<?php echo date( 'Y-m-d h:i', $event_start_date ); ?>"><?php echo date( 'l ga', $event_start_date ); ?>-<?php echo date( 'ga', $event_end_date ); ?></time>

								<?php endif; ?>

————— only past events

<?php if( $previous_events_count = get_field( 'previous_events_count' ) ): ?>
        <?php
            global $post;
            $previous_events = tribe_get_events( array( 'posts_per_page' => $previous_events_count , 'eventDisplay' => 'past' ) );

            if( $previous_events ):
        ?>
            <!--Previous Events area area-->
            <article class="events-area">
                <div class="container">

                    <?php if( $p_e_title = get_field( 'p_e_title' ) ): ?>
                        <h2 class="headline"><?php echo $p_e_title; ?></h2>
                    <?php endif; ?>

                    <div class="row no-gutters">

                        <div class="aside-col col col-xs-12"><?php the_field( 'p_e_text' ); ?></div>

                        <div class="holder col-md-8 col-xs-12">
                            <?php foreach( $previous_events as $post): setup_postdata($post); ?>
                                <?php get_template_part( 'blocks/post-preview/event' ); ?>
                            <?php endforeach; wp_reset_query(); ?>
                        </div>
                    </div>

                </div>
            </article>
            <!--end Previous area area-->
        <?php endif; ?>
    <?php endif; ?>