php插件事件日历事件日历(代码片段)

author author     2022-12-09     507

关键词:

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; ?>

php事件日历和相关插件:添加您自己的模板文件加载位置。(代码片段)

查看详情

php事件日历循环查询(代码片段)

查看详情

php事件日历:事件聚合器:永远不会导入任何场地。(代码片段)

查看详情

php事件日历:事件聚合器:覆盖导入范围默认值。(代码片段)

查看详情

php事件日历:事件聚合器:覆盖导入范围默认值。(代码片段)

查看详情

php事件日历:事件聚合器:永远不会导入任何场地。(代码片段)

查看详情

php将事件日历“所有事件”页面重定向到custonurl(代码片段)

查看详情

php事件日历:从“事件”中删除“组织者”帖子类型(代码片段)

查看详情

php事件日历:从“事件”中删除“组织者”帖子类型(代码片段)

查看详情

php禁用事件日历的restapi功能。(代码片段)

查看详情

php禁用事件日历的restapi功能。(代码片段)

查看详情

php事件日历:将“所有事件”链接转换为真正的“后退”按钮。(代码片段)

查看详情

php事件日历:将“所有事件”链接转换为真正的“后退”按钮。(代码片段)

查看详情

php事件日历pro:限制地图视图默认仅显示今天的事件。(代码片段)

查看详情

php事件日历pro:限制地图视图默认仅显示今天的事件。(代码片段)

查看详情

php事件日历:事件聚合器:查找缺少所需uid的导入ical事件。(代码片段)

查看详情

php事件日历:事件聚合器:所有导入的事件设置为特定用户作为帖子作者。(代码片段)

查看详情

php事件日历:如果用户已注销,请不要在指定的事件类别中显示事件。(代码片段)

查看详情