本文整理汇总了PHP中WP_Query::rewind_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Query::rewind_posts方法的具体用法?PHP WP_Query::rewind_posts怎么用?PHP WP_Query::rewind_posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Query
的用法示例。
在下文中一共展示了WP_Query::rewind_posts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rewind_media
public function rewind_media()
{
parent::rewind_posts();
}
示例2: placeTabboxContents
function placeTabboxContents($tb_query_args)
{
//Filters are added (and later removed) to change the output of The Loop function calls.
$tb_query = new WP_Query($tb_query_args);
$output;
//START CONTENT OUTPUT
$output .= '
<div class="tb-selector-bar">';
//Add selector bar title filter.
add_filter('the_title', 'tb_title');
if ($tb_query->have_posts()) {
while ($tb_query->have_posts()) {
$tb_query->the_post();
$output .= get_the_title($tb_query->post->ID);
}
}
$output .= '
</div>';
//Remove selector bar title filter.
remove_filter('the_title', 'tb_title');
//Add filters for actual content
add_filter('the_title', 'tbc_title');
add_filter('the_content', 'tb_content');
add_filter('post_thumbnail_html', 'tb_thumbnail');
$tb_query->rewind_posts();
if ($tb_query->have_posts()) {
while ($tb_query->have_posts()) {
$tb_query->the_post();
global $more;
$more = 0;
$output .= '
<div class="tb-content">';
$output .= get_the_title($tb_query->post->ID);
get_the_post_thumbnail($tb_query->post->ID, array(250, 250));
$content = get_the_content('<span class="readmore">Read More »</span>');
$content = apply_filters('the_content', $content);
$output .= str_replace(']]>', ']]>', $content);
$output .= '
</div>';
}
}
//END CONTENT OUTPUT
//Then the filters are removed so they don't change other posts.
remove_filter('the_title', 'tbc_title');
remove_filter('the_content', 'tb_content');
remove_filter('post_thumbnail_html', 'tb_thumbnail');
return $output;
}
示例3: array
*/
if ($featured->post_count > 1) {
wp_enqueue_script('forever-slider', get_template_directory_uri() . '/js/slider.js', array('jquery'), '13-12-2012');
?>
<nav id="feature-slider">
<ul>
<?php
/**
* Reset the counter so that we end up with matching elements
*/
$post_counter = 0;
/**
* Begin from zero
*/
$featured->rewind_posts();
/**
* Let's roll, again.
*/
while ($featured->have_posts()) {
$featured->the_post();
/**
* Make sure we don't see any posts without thumbnails
*/
if (get_the_post_thumbnail()) {
$post_counter++;
if (1 == $post_counter) {
$class = 'class="active"';
} else {
$class = '';
}
示例4: while
<?php
}
?>
<?php
}
?>
<?php
}
?>
</section>
<?php
$slides_query->rewind_posts();
?>
<?php
if ($slides_query->have_posts()) {
?>
<?php
while ($slides_query->have_posts()) {
$slides_query->the_post();
?>
<?php
if (get_field('display') !== 'slider') {
?>
示例5: getItems
function getItems($numberOfListings, $text)
{
//html
global $post;
add_image_size('slider_widget_size', 510, 300, false);
$listings = new WP_Query();
$listings->query('post_type=' . $this->post_type . '&posts_per_page=' . $numberOfListings);
if ($listings->found_posts > 0) {
?>
<div class="row">
<div class="col-md-7">
<div id="carousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php
while ($listings->have_posts()) {
$listings->the_post();
?>
<li data-target="#carousel" data-slide-to="<?php
echo $listings->current_post;
?>
" <?php
if ($listings->current_post == 0 && !is_paged()) {
echo "class=\"active\"";
}
?>
></li>
<?php
}
$listings->rewind_posts();
?>
</ol>
<div class="carousel-inner">
<?php
while ($listings->have_posts()) {
$listings->the_post();
?>
<div class="item<?php
if ($listings->current_post == 0 && !is_paged()) {
echo " active";
}
?>
">
<?php
the_post_thumbnail('slider_widget_size');
?>
</div>
<?php
}
wp_reset_postdata();
?>
</div>
</div>
</div>
<div class="col-md-5">
<section>
<p>
<?php
echo $text;
?>
</p>
</section>
</div>
</div>
<?php
} else {
echo '<p style="padding:25px;">No listing found</p>';
}
}
示例6: get_latest_news
function get_latest_news($ignore = array(), $max_categories = 3, $max_news_per_category = 3)
{
$categories = array();
$ignoreCat = $ignore;
$allCategories = get_categories();
if (count($allCategories) < $max_categories) {
$max_categories = count($allCategories);
}
while (count($categories) < $max_categories) {
list($categories, $ignoreCat) = get_latest_categories($ignoreCat);
}
$categories = array_slice($categories, 0, $max_categories);
foreach ($categories as $category) {
$args = array('posts_per_page' => $max_news_per_category, 'cat' => $category, 'post__not_in' => $ignore);
$query = new WP_Query($args);
while ($query->have_posts()) {
$query->the_post();
$ignore[] = get_the_ID();
}
$query->rewind_posts();
$news[$category] = $query;
}
return $news;
}
示例7: while
<?php
echo get_the_post_thumbnail(get_the_ID(), 'slide');
?>
<?php
if (!empty($destination)) {
echo '</a>';
}
?>
<?php
}
}
?>
</div>
<?php
$slides->rewind_posts();
?>
<div class="indicators-wrapper">
<ul class="indicators">
<?php
while ($slides->have_posts()) {
$slides->the_post();
if (has_post_thumbnail()) {
?>
<li class="indicator <?php
if ($slides->current_post == 0) {
echo 'active';
}
?>
indicator-group-<?php
示例8: while
}
$hide_title = false;
if (isset($suffusion_cpt_post_id)) {
$page_title = get_the_title($suffusion_cpt_post_id);
$hide_title = suffusion_get_post_meta($suffusion_cpt_post_id, 'suf_hide_page_title', true);
}
if ($suf_excerpt_list_count == 'all' && !$page_of_posts) {
$query_args = $wp_query->query;
$query_args['posts_per_page'] = -1;
$wp_query = new WP_Query($query_args);
} else {
if ($page_of_posts) {
query_posts('posts_per_page=-1');
} else {
// Not resetting the query_posts results skips the first entry
$wp_query->rewind_posts();
}
}
if (have_posts()) {
$suffusion_current_post_index = 0;
$suffusion_full_post_count_for_view = suffusion_get_full_content_count();
$total = $wp_query->post_count - $suffusion_full_post_count_for_view;
if ($suffusion_full_post_count_for_view > 0) {
suffusion_after_begin_content();
}
while (have_posts()) {
$suffusion_current_post_index++;
if ($suffusion_current_post_index > $suffusion_full_post_count_for_view) {
break;
}
the_post();
示例9: widget
function widget($args, $instance)
{
$cache = array();
if (!$this->is_preview()) {
$cache = wp_cache_get('widget_recent_videos', 'extra');
}
if (!is_array($cache)) {
$cache = array();
}
if (!isset($args['widget_id'])) {
$args['widget_id'] = $this->id;
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
ob_start();
extract($args);
$title = !empty($instance['title']) ? $instance['title'] : __('Recent Videos', 'extra');
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$number = !empty($instance['number']) ? absint($instance['number']) : 5;
if (!$number) {
$number = 5;
}
$recent_video_posts = new WP_Query(apply_filters('widget_recent_videos_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'tax_query' => array(array('taxonomy' => ET_POST_FORMAT, 'field' => 'slug', 'terms' => ET_POST_FORMAT_PREFIX . 'video')))));
if ($recent_video_posts->have_posts()) {
?>
<?php
echo $before_widget;
?>
<?php
if ($title) {
echo $before_title . $title . $after_title;
}
?>
<div class="widget_video_wrapper">
<img src="<?php
echo esc_url(get_template_directory_uri());
?>
/images/pagination-loading.gif" alt="<?php
_e('Loading...', 'extra');
?>
" class="widget_video_loading">
</div><!-- .widget_video_wrapper -->
<div class="widget_content">
<?php
while ($recent_video_posts->have_posts()) {
$recent_video_posts->the_post();
?>
<script type="text/template" class="widget-video-item widget-video-item-<?php
echo esc_attr(get_the_ID());
?>
">
<?php
$video_urls = get_post_meta(get_the_ID(), '_video_format_urls', true);
if (!empty($video_urls)) {
$video_embed = extra_get_video_embed($video_urls);
echo $video_embed;
// Display cover image
if (has_post_thumbnail() && $video_embed) {
$thumbnail_id = get_post_thumbnail_id();
$thumbnail_src = wp_get_attachment_image_src($thumbnail_id, extra_get_column_thumbnail_size());
if (isset($thumbnail_src[0])) {
?>
<div class="video-overlay" style="background-image: url(<?php
esc_attr_e($thumbnail_src[0]);
?>
);">
<div class="video-overlay-hover">
<a href="#" class="video-play-button"></a>
</div>
</div>
<?php
}
}
}
?>
</script><!-- .widget-video-item -->
<?php
}
?>
<script type="text/template" class="widget-video-item widget-video-item-empty">
<h4 class="no-video-title"><?php
_e('No Video Found');
?>
</h4>
</script>
</div><!-- .widget_content -->
<?php
$recent_video_posts->rewind_posts();
?>
<ul class="widget_list">
<?php
while ($recent_video_posts->have_posts()) {
$recent_video_posts->the_post();
?>
<li>
<?php
$color = extra_get_post_category_color();
//.........这里部分代码省略.........
示例10: list_all_faqs
/**
* Display FAQs in list style
*
* @since 1.0.0
* @param Array $filter_array Array of faq groups slugs
*/
private function list_all_faqs($filter_array)
{
$faqs_query_args = array('post_type' => 'faq', 'posts_per_page' => -1);
if (!empty($filter_array)) {
$faqs_query_args['tax_query'] = array(array('taxonomy' => 'faq-group', 'field' => 'slug', 'terms' => $filter_array));
}
$faqs_query = new WP_Query($faqs_query_args);
// FAQs index
if ($faqs_query->have_posts()) {
echo '<div id="qe-faqs-index" class="qe-faqs-index">';
echo '<ol class="qe-faqs-index-list">';
while ($faqs_query->have_posts()) {
$faqs_query->the_post();
?>
<li><a href="#qe-faq-<?php
the_ID();
?>
"><?php
the_title();
?>
</a></li><?php
}
echo '</ol>';
echo '</div>';
}
// rewind faqs loop
$faqs_query->rewind_posts();
// FAQs Contents
if ($faqs_query->have_posts()) {
while ($faqs_query->have_posts()) {
$faqs_query->the_post();
?>
<div id="qe-faq-<?php
the_ID();
?>
" class="qe-faq-content">
<h4><i class="fa fa-question-circle"></i> <?php
the_title();
?>
</h4>
<?php
the_content();
?>
<a class="qe-faq-top" href="#qe-faqs-index"><i class="fa fa-angle-up"></i> <?php
_e('Back to Index', 'quick-and-easy-faqs');
?>
</a>
</div>
<?php
}
}
// All the custom loops ends here so reset the query
wp_reset_query();
}
示例11: tdr_top_choices_table
function tdr_top_choices_table($args)
{
$defaults = array('number_to_show' => 3, 'number_to_query' => 3, 'offer_cat_terms' => get_terms('offer-category', array('fields' => 'ids')), 'rank_meta_key' => '');
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);
/* Set up the Query */
/* Taxonomy for the Query
* ***************************************************************/
// Set up the taxonomy
$offer_cat_args = array(array('taxonomy' => 'offer-category', 'field' => 'id', 'terms' => $offer_cat_terms));
/* Create the query
* ***************************************************************/
$basic_query = new WP_Query(array('tax_query' => $offer_cat_args, 'post_type' => 'tdr_product', 'posts_per_page' => (int) $number_to_query, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => 'thunder_plugin_products_rank'));
// If a Rank Key is defined, reorder the Products
if (!empty($rank_meta_key)) {
global $tdr_rank_key;
$tdr_rank_key = $rank_meta_key;
usort(&$basic_query->{'posts'}, 'tdr_sort_by_offer_category_rank');
$basic_query->rewind_posts();
}
// Update to only show the $number_to_show
$basic_query->post_count = $number_to_show;
$returner = '<div class="row">';
$returner .= '<div class="span">';
// Set up tdr_product
$product = new Thunder_Plugin_Products();
while ($basic_query->have_posts()) {
$basic_query->the_post();
// Get the ID for the Rating Bar, this determines how the stars appear
$internal_rating = floatval($product->get_the_internal_rating());
if ($internal_rating < 2.2) {
$internal_rating_id = 'two_zero';
} elseif ($internal_rating < 2.7) {
$internal_rating_id = 'two_five';
} elseif ($internal_rating < 3.2) {
$internal_rating_id = 'three_zero';
} elseif ($internal_rating < 3.7) {
$internal_rating_id = 'three_five';
} elseif ($internal_rating < 4.2) {
$internal_rating_id = 'four_zero';
} elseif ($internal_rating < 4.7) {
$internal_rating_id = 'four_five';
} elseif ($internal_rating >= 4.7) {
$internal_rating_id = 'five_zero';
} else {
$internal_rating_id = $internal_rating;
}
// Force display of non-significant digits for the internal rating
$internal_rating = sprintf("%1.1f", $internal_rating);
// Output a row for this Product, and get its name
$returner .= '<div class="row"><div class="span4" style="border-top: 1px solid #eee; padding: 10px 0;">';
$product_name = $product->get_the_affiliate_name();
// Get the logo, and set up link
add_image_size('our_top_choices_thumb', 120, 30);
$review_link = get_permalink();
$attr['alt'] = $product_name . ' Reviews';
$attr['title'] = $product_name . ' Reviews';
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('tdr_product', 'thumbnail-affiliate-logo')) {
$affiliate_img = MultiPostThumbnails::get_the_post_thumbnail('tdr_product', 'thumbnail-affiliate-logo', NULL, 'our_top_choices_thumb', $attr);
}
$returner .= "<div class='our_top_logos'>";
$returner .= "<a href='{$review_link}'>";
$returner .= $affiliate_img;
$returner .= '</a>';
$returner .= "</div><!-- end .our_top_logos -->";
$returner .= "<div class='our_top_ratings' style=''>";
$returner .= "<div id='{$internal_rating_id}' class='rating-bar' style='position: relative; left: 5px;'></div>";
$returner .= "<span style='font-size: 24px; font-weight: bold; line-height: 24px; '>{$internal_rating}</span>" . " <span class='review-link'>(<a href='{$review_link}' style=''>Review</a>)</span>";
$returner .= "</div>";
$returner .= "<div class='our_top_visit' style=''>";
$product_id = $product->get_the_id();
$jump_page_url = get_home_url() . "/visit?site={$product_id}&t=sidebar";
$returner .= "<a target=_blank' href='{$jump_page_url}'><span style='font-size:10px;'>▶</span> Visit Site</a>";
$returner .= "</div>";
$returner .= '</div><!-- end .span --></div><!-- end .row -->';
}
$returner .= "</div><!-- end .span -->";
$returner .= "</div><!-- end .row -->";
$returner .= '<div class="read_more_articles">';
$offer_category_permalink = get_home_url() . '/reviews';
$returner .= "<a href='{$offer_category_permalink}' id='review_page_link'>+ View All Reviews</a>";
$returner .= '</div><!-- end .read_more_articles -->';
return $returner;
}
示例12: _cacsp_archive_ob_end
/**
* Clears the buffer for content replacement on the Social Paper archive page.
*
* This is also where we call our custom directory template.
*
* @access private
*
* @param WP_Query $q
*/
function _cacsp_archive_ob_end($q)
{
if (false === Social_Paper::$is_buffer) {
return;
}
if (false === cacsp_is_archive()) {
return;
}
ob_end_clean();
remove_action('loop_end', '_cacsp_archive_ob_end', 999);
// rewind posts if papers exist to display them in our template
if (false === Social_Paper::$is_empty_archive) {
$q->rewind_posts();
}
$templates = array();
if (function_exists('buddypress')) {
$templates[] = 'content-directory-social-paper-buddypress.php';
}
$templates[] = 'content-directory-social-paper.php';
cacsp_locate_template($templates, true);
}
示例13: die
//.........这里部分代码省略.........
if ($user_wishlists->have_posts()) {
echo '<li id="wishlist_existing_li">
<h3 class="wishlist_h3_title" ><input class="wishlist_radio_toggle" checked="checked" type="radio" name="existing_or_new" value="1"> ' . __('Add Product to Existing Wishlist:', 'ignitewoo-wishlists-pro') . '</h3>
';
// NOTE TO THEMERS: This div "wishlists_list" ought to have CSS of overflow:auto; width: XXX; height: XXX
echo '<div id="wishlists_list">
<ul id="wishlist_existing_ul">';
$i = 0;
while ($user_wishlists->have_posts()) {
$user_wishlists->the_post();
$wishlist_type = wp_get_post_terms($post->ID, 'c_wishlists_cat', OBJECT);
$i++;
//if ( 1 == $i ) $checked = 'checked="checked"'; else $checked = '';
$checked = '';
echo '<li><label>
<input ' . $checked . ' class="wishlist_radio_btn" type="radio" name="existing_wishlist" value="' . $post->ID . '">
';
the_title();
if (isset($wishlist_type[0]->name)) {
echo ' (' . $wishlist_type[0]->name . ')
</label></li>';
}
}
echo '</ul>
</div></li>';
}
if ($wishlist_types) {
?>
<li id="wishlist_new_li">
<h3 class="wishlist_h3_title">
<?php
$user_wishlists->rewind_posts();
if ($user_wishlists->have_posts()) {
?>
<input class="wishlist_radio_toggle" type="radio" name="existing_or_new" value="2">
<?php
}
?>
<?php
_e('Add Product to New Wishlist', 'ignitewoo-wishlists-pro');
?>
</h3>
<div class="wishlist_new_wrap" style="display:none">
<div class="row">
<?php
$field_wishlist_type_key = "field_575726e432f3c";
$field_wishlist_type = get_field_object($field_wishlist_type_key);
?>
<div class="col-md-12">
<div class="form-group form-group-event-type"">
<?php
if ($field_wishlist_type) {
?>
<label for="event-type">Event Type</label>
<select name="event-type" id="event-type"s class="event-type">
<option value="_none">- Select a value -</option>
<?php
foreach ($field_wishlist_type['choices'] as $k => $v) {
?>
<option value="<?php
示例14: while
<?php
}
?>
<?php
}
?>
<?php
}
?>
</section>
<?php
$blocks_query->rewind_posts();
?>
<?php
if ($blocks_query->have_posts()) {
?>
<?php
while ($blocks_query->have_posts()) {
$blocks_query->the_post();
?>
<?php
if (get_field('display') !== 'slider') {
?>
示例15: array
// global $wp_query;
// $backuped_main_query = clone $wp_query;
$portfolio_query = new WP_Query($args);
if ($portfolio_query->have_posts()) {
wp_enqueue_script('zero-portfolio-cat-1-js');
$portfolioTagsArray = array();
while ($portfolio_query->have_posts()) {
$portfolio_query->the_post();
$t = wp_get_post_terms(get_the_ID(), 'ff-portfolio-tag');
if (!empty($t)) {
foreach ($t as $onePortfolioTag) {
$portfolioTagsArray[$onePortfolioTag->slug] = $onePortfolioTag;
}
}
}
$portfolio_query->rewind_posts();
$pagePortfolioShowContent = strip_tags($pagePortfolioContent);
$pagePortfolioShowContent = str_replace(' ', '', $pagePortfolioShowContent);
$pagePortfolioShowContent = trim($pagePortfolioShowContent);
$pagePortfolioShowContent = !empty($pagePortfolioShowContent);
?>
<div class="portfolio-cat-1
portfolio-cat-1--cols--xs--<?php
echo absint($column_count_xs);
?>
portfolio-cat-1--show-description--xs--<?php
echo absint($show_description_xs);
?>
portfolio-cat-1--cols--sm--<?php
echo absint($column_count_sm);