当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_query::is_singular方法代码示例

本文整理汇总了PHP中wp_query::is_singular方法的典型用法代码示例。如果您正苦于以下问题:PHP wp_query::is_singular方法的具体用法?PHP wp_query::is_singular怎么用?PHP wp_query::is_singular使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wp_query的用法示例。


在下文中一共展示了wp_query::is_singular方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: posts_where

 /**
  * Custom SQL conditional for event duration meta field
  *
  * @param string  $where_sql
  * @param wp_query $query
  * @return string
  */
 public static function posts_where($where_sql, $query)
 {
     global $wpdb;
     // if it's a true event query then we to setup where conditions
     if ($query->tribe_is_event || $query->tribe_is_event_category) {
         $start_date = !empty($query->start_date) ? $query->start_date : $query->get('start_date');
         $end_date = !empty($query->end_date) ? $query->end_date : $query->get('end_date');
         // we can't store end date directly because it messes up the distinc clause
         $event_end_date = apply_filters('tribe_events_query_end_date_column', 'tribe_event_end_date.meta_value');
         // event start date
         $event_start_date = "{$wpdb->postmeta}.meta_value";
         // build where conditionals for events if date range params are set
         if ($start_date != '' && $end_date != '') {
             $start_clause = $wpdb->prepare("({$event_start_date} >= %s AND {$event_start_date} <= %s)", $start_date, $end_date);
             $end_clause = $wpdb->prepare("({$event_end_date} >= %s AND {$event_start_date} <= %s )", $start_date, $end_date);
             $within_clause = $wpdb->prepare("({$event_start_date} < %s AND {$event_end_date} >= %s )", $start_date, $end_date);
             $where_sql .= " AND ({$start_clause} OR {$end_clause} OR {$within_clause})";
         } else {
             if ($start_date != '') {
                 $start_clause = $wpdb->prepare("{$wpdb->postmeta}.meta_value >= %s", $start_date);
                 $within_clause = $wpdb->prepare("({$wpdb->postmeta}.meta_value <= %s AND {$event_end_date} >= %s )", $start_date, $start_date);
                 $where_sql .= " AND ({$start_clause} OR {$within_clause})";
                 if ($query->is_singular() && $query->get('eventDate')) {
                     $tomorrow = date('Y-m-d', strtotime($query->get('eventDate') . ' +1 day'));
                     $tomorrow_clause = $wpdb->prepare("{$wpdb->postmeta}.meta_value < %s", $tomorrow);
                     $where_sql .= " AND {$tomorrow_clause}";
                 }
             } else {
                 if ($end_date != '') {
                     $where_sql .= " AND " . $wpdb->prepare("{$event_end_date} < %s", $end_date);
                 }
             }
         }
     }
     return $where_sql;
 }
开发者ID:paarthd,项目名称:gslvpa,代码行数:43,代码来源:tribe-event-query.class.php


注:本文中的wp_query::is_singular方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。