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


PHP wp_reset_query函数代码示例

本文整理汇总了PHP中wp_reset_query函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_reset_query函数的具体用法?PHP wp_reset_query怎么用?PHP wp_reset_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: widget

 function widget($args, $instance)
 {
     global $post;
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $title = empty($instance['title']) ? __('Recent Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']);
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $posts = new WP_Query('orderby=date&posts_per_page=' . $instance['postcount'] . '');
     while ($posts->have_posts()) {
         $posts->the_post();
         // Insert post date if needed.
         if ($instance['postdate'] == 'on') {
             $date_input = '<a href="' . get_permalink() . '" class="date">' . get_the_date('M j, Y') . '</a>';
         }
         // HTML output
         echo '<div class="recent-posts">';
         if (has_post_thumbnail() and $instance['imageswitch'] == 'on') {
             echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
         } else {
             echo '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
         }
         echo '</div>';
     }
     wp_reset_query();
     echo $after_widget;
 }
开发者ID:closings,项目名称:closings,代码行数:28,代码来源:recentposts.php

示例2: generate_ryuzine_stylesheets

function generate_ryuzine_stylesheets()
{
    // verify this came from the our screen and with proper authorization.
    if (!wp_verify_nonce($_POST['ryu_regenstyles_noncename'], 'ryuzine-regenstyles_install')) {
        return;
    }
    // Check permissions
    if (!current_user_can('administrator')) {
        echo "<div class='error'><p>Sorry, you do not have the correct priveledges to install the files.</p></div>";
        return;
    }
    $my_query = null;
    $my_query = new WP_Query(array('post_type' => 'ryuzine'));
    if ($my_query->have_posts()) {
        while ($my_query->have_posts()) {
            $my_query->the_post();
            $stylesheet = "";
            $issuestyles = get_post_meta(get_the_ID(), '_ryustyles', false);
            if (!empty($issuestyles)) {
                foreach ($issuestyles as $appendstyle) {
                    // If there are multiple ryustyles append them //
                    $stylesheet = $stylesheet . $appendstyle;
                }
            }
            if ($stylesheet != "") {
                ryu_create_css($stylesheet, get_the_ID());
            }
        }
    }
    // reset css check //
    //	update_option('ryu_css_admin',0);
    wp_reset_query();
    return;
}
开发者ID:ryumaru,项目名称:ryuzine-press,代码行数:34,代码来源:rp_generate_css.php

示例3: widget

 /**
  * Outputs the HTML for this widget.
  *
  * @param array  An array of standard parameters for widgets in this theme
  * @param array  An array of settings for this widget instance
  * @return void Echoes it's output
  */
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $title = apply_filters('widget_title', $instance['title']);
     if ($title != '') {
         echo $before_title;
         echo $title;
         echo $after_title;
     }
     // Remove the filter from the Posts Order By Plugin
     if (function_exists('CPTOrderPosts')) {
         remove_filter('posts_orderby', 'CPTOrderPosts', 99, 2);
     }
     // Get the articles
     $args = array('post_type' => 'post', 'posts_per_page' => $instance['number'], 'meta_key' => 'ipt_kb_like_article', 'meta_value' => '0', 'meta_compare' => '>', 'orderby' => 'meta_value_num', 'order' => 'DESC');
     $args = apply_filters('ipt_kb_popular_widget_query_args', $args);
     $popular_posts = new WP_Query($args);
     echo '<div class="list-group">';
     if ($popular_posts->have_posts()) {
         while ($popular_posts->have_posts()) {
             $popular_posts->the_post();
             get_template_part('category-templates/content', 'popular');
         }
     } else {
         get_template_part('category-templates/no-result');
     }
     echo '</div>';
     wp_reset_query();
     // Add the filter from the Posts Order By Plugin
     if (function_exists('CPTOrderPosts')) {
         add_filter('posts_orderby', 'CPTOrderPosts', 99, 2);
     }
     echo $after_widget;
 }
开发者ID:andychoi,项目名称:k-knowledgebase-theme-wp,代码行数:42,代码来源:class-ipt-kb-popular-widget.php

示例4: show_category

function show_category($cid = 1)
{
    $args = array('showposts' => 4, 'cat' => $cid, 'orderby' => 'post_date', 'order' => 'desc');
    query_posts($args);
    global $the_post;
    $category = '';
    while (have_posts()) {
        the_post();
        $cat = get_the_category(get_the_ID());
        $link = get_permalink(get_the_ID());
        $src = get_the_post_thumbnail(get_the_ID(), 'index_thumb');
        $c_name = $cat[0]->name;
        $title = get_the_title();
        echo $category .= <<<EOF
        <div class="box">
          <a href="{$link}">
          <div class="boximg">{$src}</div>
          <div class="category">{$c_name}</div>
          <p>{$title}</p>
          </a>
        </div>
EOF;
    }
    wp_reset_query();
    return $category;
}
开发者ID:bloemen,项目名称:success,代码行数:26,代码来源:top-category.php

示例5: zp_custom_blog_page

function zp_custom_blog_page()
{
    global $post, $paged;
    $include = genesis_get_option('blog_cat');
    $exclude = genesis_get_option('blog_cat_exclude') ? explode(',', str_replace(' ', '', genesis_get_option('blog_cat_exclude'))) : '';
    if (get_query_var('paged')) {
        $paged = get_query_var('paged');
    } elseif (get_query_var('page')) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    //* Arguments
    $args = array('cat' => $include, 'category__not_in' => $exclude, 'posts_per_page' => genesis_get_option('blog_cat_num'), 'paged' => $paged);
    query_posts($args);
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            do_action('genesis_before_entry');
            printf('<article %s>', genesis_attr('entry'));
            // check post format and call template
            $format = get_post_format();
            get_template_part('content', $format);
            do_action('genesis_after_entry_content');
            //do_action( 'genesis_entry_footer' );
            echo '</article>';
            do_action('genesis_after_entry');
        }
    }
    //* Genesis navigation
    genesis_posts_nav();
    //* Restore original query
    wp_reset_query();
}
开发者ID:lukasalbrecht,项目名称:www.genesis-playground.dev,代码行数:34,代码来源:home.php

示例6: featured_index

    function featured_index()
    {
        $output = '';
        $args = array('tag' => 'featured', 'posts_per_page' => 3);
        query_posts($args);
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $the_img = $this->get_img_src(get_the_ID());
                if ($the_img == 'zero') {
                }
                $output .= '<div class=" mdl-cell mdl-cell--4-col mdl-card mdl-shadow--2dp">';
                $output .= ' <div class="mdl-card__title mdl-card--expand" style="background-image: url( \' ' . $the_img . '  \' )">
							  </div>
							  <div class="mdl-card__supporting-text">
								' . get_the_title() . '
							  </div>
							  <div class="mdl-card__actions mdl-card--border">
								<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
								  View Updates
								</a>
							  </div>';
                $output .= '</div>';
            }
        } else {
            $output = 'gagal';
        }
        wp_reset_query();
        return $output;
    }
开发者ID:madebyaris,项目名称:arisdes-wp-blog,代码行数:30,代码来源:mdl_custom.php

示例7: widget

    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $number = $instance['number'];
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<div class="recent-works-items clearfix">
		<?php 
        $args = array('post_type' => 'evolve_portfolio', 'posts_per_page' => $number, 'has_password' => false);
        $portfolio = new WP_Query($args);
        if ($portfolio->have_posts()) {
            ?>
		<?php 
            while ($portfolio->have_posts()) {
                $portfolio->the_post();
                ?>
		<?php 
                if (has_post_thumbnail()) {
                    ?>
		<?php 
                    $link_target = "";
                    $url_check = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true);
                    if (!empty($url_check)) {
                        $new_permalink = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true);
                        if (get_post_meta(get_the_ID(), 'pyre_link_icon_target', true) == "yes") {
                            $link_target = ' target="_blank"';
                        }
                    } else {
                        $new_permalink = get_permalink();
                    }
                    ?>
		<a href="<?php 
                    echo $new_permalink;
                    ?>
"<?php 
                    echo $link_target;
                    ?>
 title="<?php 
                    the_title();
                    ?>
">
			<?php 
                    the_post_thumbnail('recent-works-thumbnail');
                    ?>
		</a>
		<?php 
                }
            }
        }
        wp_reset_query();
        ?>
		</div>

		<?php 
        echo $after_widget;
    }
开发者ID:berniecultess,项目名称:infirev,代码行数:60,代码来源:recent-works-widget.php

示例8: writeShoppingCart

function writeShoppingCart()
{
    global $wpdb;
    $settings = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "photocrati_ecommerce_settings WHERE id = 1", ARRAY_A);
    foreach ($settings as $key => $value) {
        ${$key} = $value;
    }
    $cart = $_SESSION['cart'];
    if (!$cart) {
        return '<p><em>' . $ecomm_empty . '</em> </p>';
    } else {
        // Parse the cart session variable
        $items = explode(',', $cart);
        $s = count($items) > 1 ? 's' : '';
        if (get_option('permalink_structure') != '') {
            return '<button id="addto2" class="positive" style="margin:0 5px;" onClick=\'window.location.href = "' . get_bloginfo('url') . '/' . str_replace(" ", "-", strtolower($ecomm_title)) . '/"\'><img src="' . photocrati_gallery_file_uri('image/cart.png') . '"> ' . $ecomm_title . ': ' . count($items) . ' item' . $s . '</button>';
        } else {
            $pgid = query_posts(array('pagename' => $ecomm_title));
            foreach ($pgid as $pgid) {
                $pageid = $pgid->ID;
            }
            wp_reset_query();
            return '<button id="addto2" class="positive" style="margin:0 5px;" onClick=\'window.location.href = "' . get_bloginfo('url') . '/?page_id=' . $pageid . '"\'><img src="' . photocrati_gallery_file_uri('image/cart.png') . '"> ' . $ecomm_title . ': ' . count($items) . ' item' . $s . '</button>';
        }
    }
}
开发者ID:nicoladj77,项目名称:code-veronica,代码行数:26,代码来源:ecommerce.php

示例9: sys_recent_posts

function sys_recent_posts($atts, $content = null)
{
    extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'cat_id' => '23', 'thumb' => 'true', 'postdate' => ''), $atts));
    $out = '<div class="widget_postslist sc">';
    $out .= '<ul>';
    global $wpdb;
    $myposts = get_posts("numberposts={$limit}&offset=0&cat={$cat_id}");
    foreach ($myposts as $post) {
        $post_date = $post->post_date;
        $post_date = mysql2date('F j, Y', $post_date, false);
        $out .= "<li>";
        if ($thumb == "true") {
            $thumbid = get_post_thumbnail_id($post->ID);
            $imgsrc = wp_get_attachment_image_src($thumbid, array(9999, 9999));
            $out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">';
            if ($thumbid) {
                $out .= atp_resize('', $imgsrc['0'], '50', '50', 'imgborder', '');
            } else {
                //$out .= '<img class="imgborder" src="'.THEME_URI.'/images/no-image.jpg'.'"  alt="' .$post->post_title. '" />';
            }
            $out .= '</a></div>';
        }
        $out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>';
        if ($postdate == "true") {
            $out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>';
        } else {
            $out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>';
        }
        $out .= '</div></li>';
    }
    $out .= '</ul></div>';
    return $out;
    wp_reset_query();
}
开发者ID:pryspry,项目名称:MusicPlay,代码行数:34,代码来源:recentposts.php

示例10: friend_list_func

    public static function friend_list_func($atts, $content = "")
    {
        $atts = shortcode_atts(array('per_page' => '100'), $atts, 'friend_list');
        $return = "";
        query_posts(array('post_type' => 'friend', 'showposts' => $atts['per_page'], 'meta_query' => array('relation' => 'AND', array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_male.gif', 'compare' => 'NOT LIKE'), array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_female.gif', 'compare' => 'NOT LIKE'))));
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $displayName = get_post_meta(get_the_id(), 'displayName', true);
                $avatar = get_post_meta(get_the_id(), 'avatar150', true);
                $return .= sprintf('<div class="col-lg-3 col-sm-3 focus-box">
		 								<div class="service-icon">
		 									<i style="background:url(%s) no-repeat center;width:100%%; height:100%%;" class="pixeden"></i>
		 								</div>
		 								<h3 class="red-border-bottom">%s</h3>
		 								<a class="btn btn-primary btn-block green-btn btn-sm" href="https://www.fitbit.com/user/%s"><i class="fa fa-plus"></i> Add Friend</a>
		 								<br/>
		 							</div>', $avatar, $displayName, get_the_title(), get_the_content());
            }
            $return = '<div class="hwd-wrapper"><div class="row">' . $return . '</div></div>';
        } else {
            $return = 'No Friends Found';
        }
        wp_reset_query();
        return $return;
    }
开发者ID:HealthyWebDeveloper,项目名称:HWD-friend-finder,代码行数:26,代码来源:class-friend-shortcode.php

示例11: get_post_count

 public function get_post_count($post_type = 'item')
 {
     $author_args = array('post_status' => 'publish', 'post_type' => $post_type, 'author' => $this->author->ID);
     $author_posts = query_posts($author_args);
     wp_reset_query();
     return count($author_posts);
 }
开发者ID:ksingh812,项目名称:epb,代码行数:7,代码来源:javo-author.php

示例12: widget

    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $instance = wp_parse_args($instance, array('title' => __('Closed Questions', 'dwqa'), 'number' => 5));
        echo $before_widget;
        echo $before_title;
        echo $instance['title'];
        echo $after_title;
        $args = array('post_type' => 'dwqa-question', 'meta_query' => array('relation' => 'OR', array('key' => '_dwqa_status', 'compare' => '=', 'value' => 'resolved'), array('key' => '_dwqa_status', 'compare' => '=', 'value' => 'closed')));
        $questions = new WP_Query($args);
        if ($questions->have_posts()) {
            echo '<div class="dwqa-popular-questions">';
            echo '<ul>';
            while ($questions->have_posts()) {
                $questions->the_post();
                echo '
				<li><a href="' . get_permalink() . '" class="question-title">' . get_the_title() . '</a> ' . __('asked by', 'dwqa') . ' ' . get_the_author_link();
                '</li>';
            }
            echo '</ul>';
            echo '</div>';
        }
        wp_reset_query();
        wp_reset_postdata();
        echo $after_widget;
    }
开发者ID:Korotkin-Solutions,项目名称:dw-question-answer,代码行数:26,代码来源:list-closed-question.php

示例13: film_shortcode_query

function film_shortcode_query($atts, $content)
{
    extract(shortcode_atts(array('posts_per_page' => '1', 'post_type' => 'landing', 'caller_get_posts' => 1), $atts));
    global $post;
    $posts = new WP_Query($atts);
    $output = '';
    if ($posts->have_posts()) {
        while ($posts->have_posts()) {
            $posts->the_post();
            $out = '<div class="film_box">
                <h4>Film Name: <a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h4>
                <p class="Film_desc">' . get_the_content() . '</p>';
            // add here more...
            $out .= '</div>';
            /* these arguments will be available from inside $content
                   get_permalink()  
                   get_the_content()
                   get_the_category_list(', ')
                   get_the_title()
                   and custom fields
                   get_post_meta($post->ID, 'field_name', true);
               */
        }
    } else {
        return;
    }
    // no posts found
    wp_reset_query();
    return html_entity_decode($out);
}
开发者ID:futr3,项目名称:cdt-fsf,代码行数:30,代码来源:shortcodes.php

示例14: widget

 function widget($args, $instance)
 {
     if (!is_home()) {
         return false;
     }
     /*
         Query the first post:
          If it has a featured image, display it,
          and store its ID in an array.
     */
     query_posts('posts_per_page=1');
     while (have_posts()) {
         the_post();
         $do_not_duplicate[] = $post->ID;
         get_template_part('feature', 'index');
     }
     /*
         Excerpt post loop.
          If a #feature post exists, do not duplicate.
     */
     if ((int) $instance['excerpts_count'] > 0) {
         query_posts(array('post__not_in' => $do_not_duplicate, 'offset' => 1, 'posts_per_page' => (int) $instance['excerpts_count']));
         echo '<div class="clearfix">';
         for ($post_count = 1; have_posts(); $post_count++) {
             the_post();
             $do_not_duplicate[] = $post->ID;
             /*
                 See: lib/helpers.php -> sourdough_excerpt()
             */
             sourdough_excerpt($post_count);
         }
         echo '</div>';
     }
     wp_reset_query();
 }
开发者ID:staydecent,项目名称:wp-sourdough,代码行数:35,代码来源:sourdough-featured-posts.php

示例15: adm_sitemap_posts

function adm_sitemap_posts($atts)
{
    extract(shortcode_atts(array('comments_number' => true, 'number' => '0', 'cat' => '', 'posts' => '', 'author' => '', 'type' => 'post', 'comments' => 'true'), $atts));
    if ($number == 0) {
        $number = 1000;
    }
    if ($comments_number === 'false') {
        $comments_number = false;
    }
    $query = array('showposts' => (int) $number, 'post_type' => $type);
    if ($cat) {
        $query['cat'] = $cat;
    }
    if ($posts) {
        $query['post__in'] = explode(',', $posts);
    }
    if ($author) {
        $query['author'] = $author;
    }
    $archive_query = new WP_Query($query);
    $output = '';
    while ($archive_query->have_posts()) {
        $archive_query->the_post();
        $output .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="' . sprintf(__("Permanent Link to %s", 'striking_front'), get_the_title()) . '">' . get_the_title() . '</a>';
        if ($comments == 'true') {
            $output .= $comments_number ? ' (' . get_comments_number() . ')' : '';
        }
        $output .= '</li>';
    }
    wp_reset_query();
    return '<div class="sc-sitemap sitemap-posts"><ul>' . $output . '</ul></div>';
}
开发者ID:AdmiumNL,项目名称:adm-default,代码行数:32,代码来源:inc_shortcodes.php


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