本文整理汇总了PHP中rewind_posts函数的典型用法代码示例。如果您正苦于以下问题:PHP rewind_posts函数的具体用法?PHP rewind_posts怎么用?PHP rewind_posts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rewind_posts函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: presscore_search_title_shortcode
function presscore_search_title_shortcode()
{
$title = '';
$wrap_class = '';
if (is_search()) {
$title = get_search_query();
} else {
if (is_archive()) {
if (is_category()) {
$title = single_cat_title('', false);
} elseif (is_tag()) {
$title = single_tag_title('', false);
} elseif (is_author()) {
the_post();
$title = '<a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta("ID"))) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a>';
$wrap_class .= ' vcard';
rewind_posts();
} elseif (is_day()) {
$title = '<span>' . get_the_date() . '</span>';
} elseif (is_month()) {
$title = '<span>' . get_the_date('F Y');
} elseif (is_year()) {
$title = '<span>' . get_the_date('Y');
} elseif (is_tax('dt_portfolio_category')) {
$title = single_term_title('', false);
} elseif (is_tax('dt_gallery_category')) {
$title = single_term_title('', false);
}
}
}
if ($title) {
$title = '<span' . ($wrap_class ? ' class="' . esc_attr($wrap_class) . '"' : '') . '>' . $title . '</span>';
}
return $title;
}
示例2: get_child_pages
function get_child_pages()
{
global $post;
rewind_posts();
//stops any previous loops
query_posts(array('post_type' => 'page', 'posts_per_page' => -1, 'post_status' => publish, 'post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order'));
//query and order child pages
while (have_posts()) {
the_post();
$childPermalink = get_permalink($post->ID);
//post permalink
$childID = $post->ID;
//post it
$childTitle = $post->post_title;
//post title
$childExcerpt = $post->post_excerpt;
//post excerpt
$childImage = get_the_post_thumbnail($page->ID, 'featured-spotlight');
//post thumbnail
echo '<div class="tile">';
echo '<div class="tile-image">' . $childImage . '</div>';
echo '<h1 id="cta-h1"><a href="' . $childPermalink . '">' . $childTitle . '</a></h1>';
echo '<p class="caption"><a href="' . $childPermalink . '"><span>' . $childExcerpt . '</span></a></p>';
echo '</div>';
}
wp_reset_query();
// reset query
}
示例3: get_child_pages
function get_child_pages()
{
global $post;
rewind_posts();
// stop any previous loops
query_posts(array('post_type' => 'page', 'posts_per_page' => -1, 'post_status' => publish, 'post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order'));
// query and order child pages
while (have_posts()) {
the_post();
$childPermalink = get_permalink($post->ID);
// post permalink
$childID = $post->ID;
// post id
$childTitle = $post->post_title;
// post title
$childExcerpt = $post->post_excerpt;
// post excerpt
echo '<article id="page-excerpt-' . $childID . '" class="page-excerpt">';
echo '<h3><a href="' . $childPermalink . '">' . $childTitle . ' »</a></h3>';
echo '<p>' . $childExcerpt . ' <a href="' . $childPermalink . '">Read More »</a></p>';
echo '</article>';
}
// reset query
wp_reset_query();
}
示例4: get_child_pages
function get_child_pages()
{
global $post;
rewind_posts();
// stop any previous loops
query_posts(array('post_type' => 'page', 'posts_per_page' => -1, 'post_status' => publish, 'post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order'));
// query and order child pages
while (have_posts()) {
the_post();
$childPermalink = get_permalink($post->ID);
// post permalink
$childID = $post->ID;
// post id
$childTitle = $post->post_title;
// post title
$childExcerpt = $post->post_excerpt;
// post excerpt
echo '<article id="page-excerpt-' . $childID . '" class="box-left">';
echo '<div class="section-box">';
echo '<p id="button"><a href="' . $childPermalink . '">' . $childTitle . '</a></p>';
echo '</div>';
echo '<div class="section-boxes">';
echo '<p id>' . $childExcerpt . ' <a href="' . $childPermalink . '">';
?>
<i class="fa fa-arrow-circle-right"></i> <?php
'</a></p>';
echo '</div>';
echo '</article>';
}
// reset query
wp_reset_query();
}
示例5: widget
/**
* @param array $args
* @param array $instance
*/
function widget($args, $instance)
{
if (empty($instance['template'])) {
return;
}
if (is_admin()) {
return;
}
echo $args['before_widget'];
$instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
if (!empty($instance['title'])) {
echo $args['before_title'] . $instance['title'] . $args['after_title'];
}
if (strpos('/' . $instance['template'], '/content') !== false) {
while (have_posts()) {
the_post();
locate_template($instance['template'], true, false);
}
} else {
locate_template($instance['template'], true, false);
}
echo $args['after_widget'];
// Reset everything
rewind_posts();
wp_reset_postdata();
}
示例6: header_function
function header_function()
{
global $vertical;
if (!is_single() && is_home() && !is_archive()) {
query_posts("what_to_show=posts&posts_per_page=1");
}
if (!is_archive() && !is_search()) {
?>
<style type="text/css" media="screen">
<?php
while (have_posts()) {
the_post();
// ececute the specific stylesheet
print_stylesheet();
// determine if an image is vertical or not
if (is_vertical(the_image_url(true))) {
$vertical = true;
}
}
rewind_posts();
?>
</style>
<?php
}
}
示例7: blog_summary_shortcode
function blog_summary_shortcode($attr)
{
// Describes what attributes to parse from shortcode; only 'count'
extract(shortcode_atts(array('count' => '5', 'grouptag' => 'ul', 'entrytag' => 'li', 'titletag' => 'h4', 'datetag' => 'span', 'commentstag' => 'span', 'summarytag' => 'div'), $attr));
// Queries to populate our loop based on shortcode count attribute
$r = new WP_Query("showposts={$count}&what_to_show=posts&nopaging=0&post_status=publish");
// Only run if we have posts; can't run this through searches
if ($r->have_posts() && !is_search()) {
// If we're using a Sandbox-friendly theme . . .
if (function_exists('sandbox_body_class')) {
// We can't have double hfeed classes, otherwise it won't parse
$groupclasses = 'xoxo';
} else {
// Otherwise, use hfeed to ensure hAtom compliance
$groupclasses = 'xoxo hfeed';
}
// Begin the output for shortcode and inserts in the group tag what classes we have
$output = '<' . $grouptag . ' class="' . $groupclasses . '">';
// Begins our loop for returning posts
while ($r->have_posts()) {
// Sets which post from our loop we're at
$r->the_post();
// Allows the_date() with multiple posts within a single day
unset($previousday);
// If we're using a Sandbox-friendly theme . . .
if (function_exists('sandbox_post_class')) {
// Let's use semantic classes with each entry element
$entryclasses = sandbox_post_class(false);
} else {
// Otherwise, use hentry to ensure hAtom compliance
$entryclasses = 'hentry';
}
// Begin entry wrapper and inserts what classes we got from above
$output .= "\n" . '<' . $entrytag . ' class="' . $entryclasses . '">';
// Post title
$output .= "\n" . '<' . $titletag . ' class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf(__('Permalink to %s', 'blog_summary'), the_title_attribute('echo=0')) . '" rel="bookmark">' . get_the_title() . '</a></' . $titletag . '>';
// Post date with hAtom support
$output .= "\n" . '<' . $datetag . ' class="entry-date"><abbr class="published" title="' . get_the_time('Y-m-d\\TH:i:sO') . '">' . sprintf(__('%s', 'blog_summary'), the_date('', '', '', false)) . '</abbr></' . $datetag . '>';
// Comments number
$output .= "\n" . '<' . $commentstag . ' class="entry-comments"><a href="' . get_permalink() . '#comments" title="' . sprintf(__('Comments to %s', 'blog_summary'), the_title_attribute('echo=0')) . '">' . sprintf(__('Comments (%s)', 'blog_summary'), apply_filters('comments_number', get_comments_number())) . '</a></' . $commentstag . '>';
// Post excerpt with hAtom support
$output .= "\n" . '<' . $summarytag . ' class="entry-summary">' . "\n" . apply_filters('the_excerpt', get_the_excerpt()) . '</' . $summarytag . '>';
// Close each post LI
$output .= "\n" . '</' . $entrytag . '>';
// Finish the have_posts() query
}
// while ( $r->have_posts() ) :
// Close the parent UL
$output .= "\n" . '</' . $grouptag . '>';
// Rewinds loop from $r->the_post();
rewind_posts();
// End the initial IF statement
}
// if ( $r->have_posts() ) :
// Clears our query to put the loop back where it was
wp_reset_query();
// $r = new WP_Query()
// Returns $output to the shortcode
return $output;
}
示例8: scripts
function scripts()
{
global $wp_query;
rewind_posts();
if (have_posts()) {
$languages = array();
$theme = 'tomorrow-night';
while (have_posts()) {
the_post();
$data = get_field('code_blocks');
if (!empty($data)) {
foreach ($data as $chunk) {
if ($chunk['language'] != 'none') {
$languages[] = $chunk['language'];
}
}
}
}
if (count($languages) > 0) {
$theme_url = plugins_url('css/rainbow/' . $theme . '.css', CODEBLOCKS);
$theme_url = apply_filters('codeblocks/rainbow_theme', $theme_url);
if (!is_null($theme_url)) {
if (is_string($theme_url)) {
wp_enqueue_style('rainbow-' . $theme, $theme_url);
}
wp_enqueue_script('rainbow', plugins_url('js/rainbow.js', CODEBLOCKS));
}
}
wp_reset_query();
}
}
示例9: rewind
function rewind()
{
if ($this->WP_Query) {
$this->WP_Query->rewind_posts();
} else {
rewind_posts();
}
$this->position = 0;
}
示例10: wildcat_show404
function wildcat_show404($template)
{
global $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('pagename=error');
$wp_query->the_post();
$template404 = get_page_template();
rewind_posts();
return $template404;
}
示例11: rt_insert_custom_css
function rt_insert_custom_css()
{
if (is_page() || is_single()) {
if (have_posts()) {
while (have_posts()) {
the_post();
echo '<style type="text/css" media="screen">' . get_post_meta(get_the_ID(), 'rt_custom_css', true) . '</style>';
}
}
rewind_posts();
}
}
示例12: thinkup_title_select
function thinkup_title_select()
{
global $post;
if (is_page()) {
printf(__('%s', 'sento'), get_the_title());
} elseif (is_attachment()) {
printf(__('Blog Post Image: ', 'sento') . '%s', esc_attr(get_the_title($post->post_parent)));
} else {
if (is_single()) {
printf(__('%s', 'sento'), get_the_title());
} else {
if (is_search()) {
printf(__('Search Results: ', 'sento') . '%s', get_search_query());
} else {
if (is_404()) {
printf(__('Page Not Found', 'sento'));
} else {
if (is_category()) {
printf(__('Category Archives: ', 'sento') . '%s', single_cat_title('', false));
} elseif (is_tag()) {
printf(__('Tag Archives: ', 'sento') . '%s', single_tag_title('', false));
} elseif (is_author()) {
the_post();
printf(__('Author Archives: ', 'sento') . '%s', get_the_author());
rewind_posts();
} elseif (is_day()) {
printf(__('Daily Archives: ', 'sento') . '%s', get_the_date());
} elseif (is_month()) {
printf(__('Monthly Archives: ', 'sento') . '%s', get_the_date('F Y'));
} elseif (is_year()) {
printf(__('Yearly Archives: ', 'sento') . '%s', get_the_date('Y'));
} elseif (is_post_type_archive('portfolio')) {
printf(__('Portfolio', 'sento'));
} elseif (is_post_type_archive('client')) {
printf(__('Our Clients', 'sento'));
} elseif (is_post_type_archive('team')) {
printf(__('Our Team', 'sento'));
} elseif (is_post_type_archive('testimonial')) {
printf(__('Customer Testimonials', 'sento'));
} elseif (is_post_type_archive('product') and function_exists('thinkup_woo_titleshop_archive')) {
printf(thinkup_woo_titleshop_archive());
} elseif (thinkup_check_isblog()) {
printf(__('Blog', 'sento'));
} elseif (is_tax()) {
echo get_queried_object()->name;
} else {
printf(__('%s', 'sento'), get_the_title());
}
}
}
}
}
}
示例13: wptouch_fdn_is_custom_latest_posts_page
function wptouch_fdn_is_custom_latest_posts_page()
{
global $post;
$settings = foundation_get_settings();
if ($settings->latest_posts_page == 'none') {
return false;
} else {
rewind_posts();
wptouch_the_post();
rewind_posts();
return apply_filters('foundation_is_custom_latest_posts_page', $settings->latest_posts_page == $post->ID);
}
}
示例14: add_og_elements
public function add_og_elements()
{
$this->_metas['og:site_name'] = strip_tags(get_bloginfo('name'));
$this->_metas['og:locale'] = strtolower(str_replace('-', '_', get_bloginfo('language')));
$this->_metas['og:type'] = $this->_get_type();
/*$img = $this->_add_image();
if($img)
$this->_metas['og:image'] = $img;*/
if (is_home()) {
$this->_metas['og:title'] = NY_OG_Main_Admin::option('blog_title');
$posts_page_id = get_option('page_for_posts');
if ($posts_page_id) {
$this->_metas['og:url'] = get_permalink($posts_page_id);
} else {
$this->_metas['og:url'] = site_url();
}
$this->_metas['og:description'] = NY_OG_Main_Admin::option('blog_description');
$this->_add_image();
} else {
if (is_front_page()) {
$this->_metas['og:title'] = NY_OG_Main_Admin::option('home_title');
$this->_metas['og:url'] = site_url();
$this->_metas['og:description'] = stripslashes(NY_OG_Main_Admin::option('home_description'));
$this->_add_image();
} else {
if (is_singular()) {
the_post();
$this->_metas['og:title'] = $this->_get_title();
$this->_metas['og:url'] = get_permalink();
$this->_metas['og:description'] = $this->_get_description();
$this->_add_image();
rewind_posts();
} else {
if (is_tax() or is_category() or is_tag()) {
$this->_metas['og:title'] = $this->get_tax_data('title');
$this->_metas['og:url'] = $this->get_tax_data('link');
$description = $this->get_tax_data('description');
if ($description) {
$this->_metas['og:description'] = $description;
}
$image = NY_OG_Main_Admin::option('image');
if ($image) {
$this->_metas['og:image'] = $image;
}
}
}
}
}
$this->_output();
}
示例15: __construct
/**
* Constructs PostIterator
*/
public function __construct()
{
$this->valid = function () {
return have_posts();
};
$this->current = function () {
global $post;
the_post();
return $post;
};
$this->rewind = function () {
rewind_posts();
};
}