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


PHP WP_Query::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Initialize class
  * @param array $args
  * @access public
  * @since  2.0
  */
 public function __construct($args = array())
 {
     $paged = get_query_var('paged') ? get_query_var('paged') : 1;
     if (isset($args['post_parent'])) {
         $post_parent = $args['post_parent'];
     } else {
         $post_parent = get_query_var('parent') ? get_query_var('parent') : false;
     }
     $defaults = array('showposts' => ap_opt('question_per_page'), 'paged' => $paged);
     $args['post_status'][] = 'publish';
     $args['post_status'][] = 'closed';
     if ($post_parent) {
         $this->args['post_parent'] = $post_parent;
     }
     $this->args = wp_parse_args($args, $defaults);
     if (get_query_var('ap_s') != '') {
         $this->args['s'] = sanitize_text_field(get_query_var('ap_s'));
     }
     if (isset($this->args['sortby'])) {
         $this->orderby_questions();
     }
     $this->args['post_type'] = 'question';
     $args = $this->args;
     /**
      * Initialize parent class
      */
     parent::__construct($args);
 }
开发者ID:haythameyd,项目名称:powrly,代码行数:34,代码来源:question-loop.php

示例2: __construct

 /**
  * Initialize class
  * @param array $args Query arguments.
  * @access public
  * @since  2.0
  */
 public function __construct($args = array())
 {
     global $answers;
     $paged = get_query_var('paged') ? get_query_var('paged') : 1;
     $defaults = array('question_id' => get_question_id(), 'ap_answers_query' => true, 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'only_best_answer' => false, 'include_best_answer' => false);
     $args['post_status'][] = 'publish';
     $args['post_status'][] = 'closed';
     $this->args = wp_parse_args($args, $defaults);
     if (isset($this->args['question_id'])) {
         $question_id = $this->args['question_id'];
     }
     if (!empty($question_id)) {
         $this->args['post_parent'] = $question_id;
     }
     if (isset($this->args['sortby'])) {
         $this->orderby_answers();
     }
     // Check if requesting only for best Answer
     if (isset($this->args['only_best_answer']) && $this->args['only_best_answer']) {
         $this->args['meta_query'] = array(array('key' => ANSPRESS_BEST_META, 'type' => 'BOOLEAN', 'compare' => '=', 'value' => '1'));
     }
     $this->args['post_type'] = 'answer';
     $args = $this->args;
     /**
      * Initialize parent class
      */
     parent::__construct($args);
 }
开发者ID:troe,项目名称:anspress,代码行数:34,代码来源:answer-loop.php

示例3: array

 function __construct($args)
 {
     $this->args = $args;
     add_filter('posts_fields', array($this, 'posts_fields'));
     add_filter('posts_orderby', array($this, 'posts_orderby'));
     parent::__construct($args);
     remove_filter('posts_fields', array($this, 'posts_fields'));
     remove_filter('posts_orderby', array($this, 'posts_orderby'));
 }
开发者ID:JulieKuehl,项目名称:auburn-agency,代码行数:9,代码来源:wp-posts-carousel-popular-posts-query.class.php

示例4: __construct

 /**
  * Class constructor
  *
  * @param array|string $query_args
  *
  * @access public
  */
 public function __construct($query_args = null)
 {
     if (isset($query_args['post_type']) && $query_args['post_type'] instanceof PostTypeInterface) {
         $this->setPostType($query_args['post_type']);
         unset($query_args['post_type']);
     }
     if (isset($query_args['meta_box'])) {
         $this->setMetaBox($query_args['meta_box']);
     }
     parent::__construct($query_args);
 }
开发者ID:silversite,项目名称:silverwp,代码行数:18,代码来源:Query.php

示例5: array

 /**
  * Constructor
  *
  * @param int $post_id
  *
  * @return object WP_Query
  */
 function __construct($post_id, $args = array())
 {
     $this->post = get_post($post_id);
     $defaults = array('post_type' => $this->post->post_type, 'posts_per_page' => 5, 'post__not_in' => array($post_id));
     $this->args = wp_parse_args($args, $defaults);
     $related = $this->get_related($this->post->ID);
     if ($related) {
         parent::__construct(wp_parse_args(array('post__in' => $related, 'orderby' => 'post__in'), $this->args));
     } else {
         parent::__construct(array());
     }
 }
开发者ID:trendwerk,项目名称:related,代码行数:19,代码来源:class-tp-related.php

示例6: __construct

 /**
  * The constructor
  *
  * @since  0.0.1
  * @param  array $args
  * @return object WP_Query
  */
 public function __construct($args = array())
 {
     $this->args = $args;
     // If posts_per_page is -1, then there's no limit set,
     // but we do need a limit to be able to keep the order of UNION sub-queries:
     // @see http://stackoverflow.com/a/7587423/2078474
     if (isset($this->args['posts_per_page']) && '-1' == $this->args['posts_per_page']) {
         $this->args['posts_per_page'] = 999999;
     }
     // Remove SQL_CALC_FOUND_ROWS from the SQL query:
     $this->args['no_found_rows'] = 1;
     // Create an empty query:
     add_filter('posts_request', array($this, 'posts_request'), PHP_INT_MAX);
     // Call the parent WP_Query constructor:
     parent::__construct($this->args);
 }
开发者ID:egill,项目名称:wp-combine-queries,代码行数:23,代码来源:class.wp-query-empty.php

示例7: GuestParties

 function GuestParties()
 {
     parent::__construct(array('post_type' => 'wedding_guests', 'nopaging' => true));
     foreach ($this->posts as $post) {
         $post->guests = new GuestParty($post->ID);
         $this->total_guests += $post->guests->num_guests;
         $this->attending_wedding += $post->guests->attending_wedding;
         $this->attending_dinner += $post->guests->attending_dinner;
     }
     $this->parties = $this->posts;
     $do_not_unset = array('total_guests', 'parties', 'attending_wedding', 'attending_dinner');
     foreach ($this as $key => $val) {
         if (!in_array($key, $do_not_unset)) {
             unset($this->{$key});
         }
     }
 }
开发者ID:ryanbagwell,项目名称:Wordpress-Weddings,代码行数:17,代码来源:class.guests.php

示例8: __construct

 /**
  * The constructor
  *
  * @since  0.0.1
  * @param  array $args
  * @return object WP_Query
  */
 public function __construct($args = array())
 {
     // Default setup:
     $defaults = array('posts_per_page' => 10, 'paged' => 1, 'union' => 'UNION', 'args' => array());
     $this->args = wp_parse_args($args, $defaults);
     // Make sure paged > 0:
     $this->args['paged'] = 0 < $this->args['paged'] ? $this->args['paged'] : 1;
     // Make sure offset >= 0:
     $this->args['offset'] = isset($this->args['offset']) ? (int) $this->args['offset'] : 0;
     // Make sure we have UNION or UNION ALL:
     $this->args['union'] = !in_array(strtoupper($this->args['union']), array('UNION', 'UNION ALL')) ? $this->args['union'] : 'UNION';
     // Setup SQL generation:
     add_filter('posts_request', array($this, 'posts_request'), PHP_INT_MAX);
     // Setup SQL generation:
     add_filter('posts_orderby', array($this, 'posts_orderby'), PHP_INT_MAX);
     // Setup parent WP_Query constructor:
     $parents_args = array();
     // posts_per_page:
     if (isset($this->args['posts_per_page'])) {
         $parents_args['posts_per_page'] = $this->args['posts_per_page'];
     }
     // order:
     if (isset($this->args['order'])) {
         $parents_args['order'] = $this->args['order'];
     }
     // orderby:
     if (isset($this->args['orderby'])) {
         $parents_args['orderby'] = $this->args['orderby'];
     }
     // offset:
     if (isset($this->args['offset'])) {
         $parents_args['offset'] = $this->args['offset'];
     }
     // paged:
     if (isset($this->args['paged'])) {
         $parents_args['paged'] = $this->args['paged'];
     }
     // Call the parent WP_Query constructor:
     parent::__construct($parents_args);
 }
开发者ID:egill,项目名称:wp-combine-queries,代码行数:47,代码来源:class.wp-combine-queries.php

示例9: __construct

 /**
  * Build the query args.
  *
  * @since 1.0.0
  * @uses p2p_type()
  *
  * @todo Add context arg.
  * @see audiotheme_gig_query()
  *
  * @param array $args WP_Query args.
  */
 public function __construct($args = array())
 {
     $args = wp_parse_args($args, array('post_status' => 'publish', 'posts_per_page' => get_option('posts_per_page'), 'meta_key' => '_audiotheme_gig_datetime', 'orderby' => 'meta_value', 'order' => 'asc', 'ignore_sticky_posts' => true, 'meta_query' => array(array('key' => '_audiotheme_gig_datetime', 'value' => date('Y-m-d', current_time('timestamp')), 'compare' => '>=', 'type' => 'DATETIME'))));
     $args = apply_filters('audiotheme_gig_query_args', $args);
     $args['post_type'] = 'audiotheme_gig';
     parent::__construct($args);
     p2p_type('audiotheme_venue_to_gig')->each_connected($this);
 }
开发者ID:sewmyheadon,项目名称:audiotheme,代码行数:19,代码来源:gigs.php

示例10: __construct

 public function __construct($query = '')
 {
     parent::__construct($query);
     $this->posts = array();
     $this->query($query);
 }
开发者ID:markc,项目名称:mediapress,代码行数:6,代码来源:class-mpp-cached-media-query.php

示例11: array

 /**
  * Extend WP_Query with some predefined defaults to query
  * only campaign items.
  *
  * @since Astoundify Crowdfunding 0.1-alpha
  *
  * @param array $args
  * @return void
  */
 function __construct($args = array())
 {
     $defaults = array('post_type' => array('download'), 'posts_per_page' => get_option('posts_per_page'));
     $args = wp_parse_args($args, $defaults);
     parent::__construct($args);
 }
开发者ID:unclebrain,项目名称:appthemer-crowdfunding,代码行数:15,代码来源:theme-stuff.php

示例12: array

 /**
  * EE_Event_List_Query Constructor	 *
  * sets up a WordPress query
  *
  * @param array $args
  * @return \EE_Event_List_Query
  */
 function __construct($args = array())
 {
     //		printr( $args, '$args  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     // incoming args could be a mix of WP query args + EE shortcode args
     foreach ($args as $key => $value) {
         $property = '_' . $key;
         // if the arg is a property of this class, then it's an EE shortcode arg
         if (EEH_Class_Tools::has_property($this, $property)) {
             // set the property value
             $this->{$property} = $value;
             // then remove it from the array of args that will later be passed to WP_Query()
             unset($args[$key]);
         }
     }
     // setup the events list query
     EE_Registry::instance()->load_helper('Event_Query');
     EEH_Event_Query::filter_query_parts();
     EEH_Event_Query::set_query_params($this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort);
     // first off, let's remove any filters from previous queries
     remove_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'));
     remove_all_filters('FHEE__content_espresso_events__event_class');
     // Event List Title ?
     add_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'), 10, 1);
     // add the css class
     add_filter('FHEE__content_espresso_events__event_class', array($this, 'event_list_css'), 10, 1);
     // the current "page" we are viewing
     $paged = max(1, get_query_var('paged'));
     // Force these args
     $args = array_merge($args, array('post_type' => 'espresso_events', 'posts_per_page' => $this->_limit, 'update_post_term_cache' => FALSE, 'update_post_meta_cache' => FALSE, 'paged' => $paged, 'offset' => ($paged - 1) * $this->_limit));
     // run the query
     parent::__construct($args);
 }
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:39,代码来源:EES_Espresso_Events.shortcode.php

示例13:

 function __construct($query = '')
 {
     parent::__construct($query);
 }
开发者ID:sawan34,项目名称:tanzi,代码行数:4,代码来源:index.php

示例14: __construct

 public function __construct($query = '')
 {
     $this->post_type = mpp_get_gallery_post_type();
     parent::__construct($query);
 }
开发者ID:markc,项目名称:mediapress,代码行数:5,代码来源:class-mpp-gallery-query.php

示例15: __construct

 public function __construct($query)
 {
     global $wpdb;
     $query = (array) $query;
     $key = md5(json_encode($query));
     $this->key_string = 'mdf_pcache_' . $key;
     $this->cache_table = $wpdb->prefix . 'postmeta';
     //***
     $value = $this->get_cache_value();
     if (!empty($value) and is_array($value)) {
         $this->posts_ids = $value;
         $query['post__in'] = $this->posts_ids;
         //unset($query['posts_per_page']);
         //unset($query['orderby']);
         //unset($query['order']);
         unset($query['meta_query']);
         unset($query['tax_query']);
         //unset($query['paged']);
         //modified $query
         parent::__construct($query);
         $this->found_posts = 13;
         //$this->post_count=13;
         $this->max_num_pages = 2;
     } else {
         parent::__construct($query);
         $this->posts_ids = wp_list_pluck($this->posts, 'ID');
         $this->set_cache_value();
     }
 }
开发者ID:Lumbe,项目名称:dev_servus,代码行数:29,代码来源:core.php


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