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


PHP WP_Query::is_feed方法代码示例

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


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

示例1: first_post_full_length_enable

/**
 * @param WP_Query $query
 */
function first_post_full_length_enable($query)
{
    if (!is_admin() && $query->is_main_query() && !$query->is_feed()) {
        // set is_feed to true, so that the post content will be used in full length
        $query->is_feed = true;
        // add a filter that sets is_feed to false again, as soon as the content from the first post was set
        add_filter('the_post', 'first_post_full_length_disable');
    }
}
开发者ID:2ndkauboy,项目名称:first-post-full-length,代码行数:12,代码来源:first-post-full-length.php

示例2: include_in_feeds

	/**
	 * Anywhere that a feed is displaying posts, show comics too.
	 *
	 * @param WP_Query $query
	 */
	public function include_in_feeds( $query ) {
		if ( ! $query->is_feed() )
			return;

		// Don't modify the query if the post type isn't public.
		if ( ! get_post_type_object( 'jetpack-comic' )->public )
			return;

		$query_post_types = $query->get( 'post_type' );

		if ( empty( $query_post_types ) )
			$query_post_types = 'post';

		if ( ! is_array( $query_post_types ) )
			$query_post_types = array( $query_post_types );

		if ( in_array( 'post', $query_post_types ) ) {
			$query_post_types[] = self::POST_TYPE;
			$query->set( 'post_type', $query_post_types );
		}
	}
开发者ID:pauEscarcia,项目名称:AIMM,代码行数:26,代码来源:COMICS.PHP

示例3: eventorganiser_is_event_query

/**
 * Checks whether a given query is for events
 * @package event-query-functions
 * @param WP_Query $query The query to test
 * @param bool $exclusive Whether to test if the query is *exclusively* for events, or can include other post types
 * @return bool True if the query is an event query. False otherwise.
 */
function eventorganiser_is_event_query($query, $exclusive = false)
{
    $post_types = $query->get('post_type');
    if ('any' == $post_types) {
        $post_types = get_post_types(array('exclude_from_search' => false));
    }
    if ($post_types == 'event' || array('event') == $post_types) {
        $bool = true;
    } elseif ($query && $query->is_feed('eo-events') || is_feed('eo-events')) {
        $bool = true;
    } elseif (empty($post_types) && eo_is_event_taxonomy($query)) {
        //Querying by taxonomy - check if 'event' is the only post type
        $post_types = array();
        $taxonomies = wp_list_pluck($query->tax_query->queries, 'taxonomy');
        foreach (get_post_types() as $pt) {
            if (version_compare('3.4', get_bloginfo('version')) <= 0) {
                $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
            } else {
                //Backwards compat for 3.3
                $object_taxonomies = $pt === 'attachment' ? array() : get_object_taxonomies($pt);
            }
            if (array_intersect($taxonomies, $object_taxonomies)) {
                $post_types[] = $pt;
            }
        }
        if (in_array('event', $post_types)) {
            if ($exclusive && 1 == count($post_types)) {
                $query->set('post_type', 'event');
                $bool = true;
            } elseif (!$exclusive) {
                $bool = true;
            } else {
                $bool = false;
            }
        } else {
            $bool = false;
        }
    } elseif ($exclusive) {
        $bool = false;
    } elseif (is_array($post_types) && in_array('event', $post_types)) {
        $bool = true;
    } else {
        $bool = false;
    }
    return apply_filters('eventorganiser_is_event_query', $bool, $query, $exclusive);
}
开发者ID:windyjonas,项目名称:fredrika,代码行数:53,代码来源:event-organiser-archives.php

示例4:

 /**
  * Filter the SQL query to not include posts with empty content -- FB will complain.
  *
  * @since 0.1
  * @param string   $where  The original where part of the SQL statement.
  * @param WP_Query $query  The WP_Query instance.
  * @return string  The modified where part of the SQL statement.
  */
 function instant_articles_query_where($where, $query)
 {
     // Don’t modify the SQL query with a potentially expensive WHERE clause if we’re OK with fewer posts than 100 and are OK with filtering in the loop.
     if (defined('INSTANT_ARTICLES_LIMIT_POSTS') && INSTANT_ARTICLES_LIMIT_POSTS) {
         return $where;
     }
     if ($query->is_main_query() && $query->is_feed(INSTANT_ARTICLES_SLUG)) {
         global $wpdb;
         $where .= " AND {$wpdb->posts}.post_content NOT LIKE ''";
     }
     return $where;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:20,代码来源:facebook-instant-articles.php

示例5: eventorganiser_is_event_query

/**
 * Checks whether a given query is for events
 * @package event-query-functions
 * @param WP_Query $query The query to test
 * @param bool $exclusive Whether to test if the query is *exclusively* for events, or can include other post types
 * @return bool True if the query is an event query. False otherwise.
 */
function eventorganiser_is_event_query($query, $exclusive = false)
{
    $post_types = $query->get('post_type');
    if ('any' == $post_types) {
        $post_types = get_post_types(array('exclude_from_search' => false));
    }
    if ($post_types == 'event' || array('event') == $post_types) {
        $bool = true;
    } elseif ($query && $query->is_feed('eo-events') || is_feed('eo-events')) {
        $bool = true;
    } elseif (empty($post_types) && eo_is_event_taxonomy($query)) {
        //Querying by taxonomy - check if 'event' is the only post type
        $post_types = array();
        $taxonomies = wp_list_pluck($query->tax_query->queries, 'taxonomy');
        foreach (get_post_types() as $pt) {
            if (version_compare('3.4', get_bloginfo('version')) <= 0) {
                $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
            } else {
                //Backwards compat for 3.3
                $object_taxonomies = $pt === 'attachment' ? array() : get_object_taxonomies($pt);
            }
            if (array_intersect($taxonomies, $object_taxonomies)) {
                $post_types[] = $pt;
            }
        }
        if (in_array('event', $post_types)) {
            if ($exclusive && 1 == count($post_types)) {
                $query->set('post_type', 'event');
                $bool = true;
            } elseif (!$exclusive) {
                $bool = true;
            } else {
                $bool = false;
            }
        } else {
            $bool = false;
        }
    } elseif ($exclusive) {
        $bool = false;
    } elseif (is_array($post_types) && in_array('event', $post_types)) {
        $bool = true;
    } else {
        $bool = false;
    }
    /**
     * Filters whether the query is an event query.
     * 
     * This should be `true` if the query is for events, `false` otherwise. The 
     * third parameter, `$exclusive` qualifies if this means 'query exclusively 
     * for events' or not. If `true` then this filter should return `true` only 
     * if the query is exclusively for events.
     * 
     * @param bool     $bool      Whether the query is an event query.
     * @param WP_Query $query     The WP_Query instance to check.
     * @param bool     $exclusive Whether the check if for queries exclusively for events. 
     */
    return apply_filters('eventorganiser_is_event_query', $bool, $query, $exclusive);
}
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:65,代码来源:event-organiser-archives.php

示例6: pre_get_posts

 /**
  * Modify the query before getting any posts.
  *
  * @param  WP_Query $query WP Query object
  *
  * @return void
  */
 public function pre_get_posts(WP_Query $query)
 {
     $feed_slug = apply_filters('simple_fb_feed_slug', $this->token);
     if ($query->is_main_query() && $query->is_feed($feed_slug)) {
         $query->set('posts_per_rss', intval(apply_filters('simple_fb_posts_per_rss', get_option('posts_per_rss', 10))));
         // Allow easy access to modify query args for the FB IA feed.
         do_action('simple_fb_pre_get_posts', $query);
     }
 }
开发者ID:andfinally,项目名称:Simple-Instant-Articles-for-Facebook,代码行数:16,代码来源:simple-fb-instant-articles.php


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