本文整理汇总了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');
}
}
示例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 );
}
}
示例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);
}
示例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;
}
示例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);
}
示例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