• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_reset_postdata函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: charity_vc_our_mission

function charity_vc_our_mission($atts, $content = null)
{
    extract(shortcode_atts(array('our_mission' => ''), $atts));
    $page_id = get_page_by_title($our_mission);
    $missionQuery = new WP_Query(array("page_id" => $page_id->ID));
    if ($missionQuery->have_posts()) {
        $missionQuery->the_post();
        $url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
        ?>
        <!-- Save Lives Section Start Here-->
        <section class="save-lives text-center parallax" style="background-image: url('<?php 
        echo esc_url($url[0]);
        ?>
')">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
                        <header class="page-header">
                            <h2><?php 
        the_title();
        ?>
</h2>
                            <?php 
        the_content();
        ?>
                        </header>
                    </div>
                </div>
            </div>
        </section>
        <!-- Save Lives Section Start Here-->
    <?php 
    }
    wp_reset_postdata();
}
开发者ID:kautzar,项目名称:drpp4,代码行数:35,代码来源:our-mission.php


示例2: widget

 function widget($args, $instance)
 {
     ob_start();
     extract($args);
     $title = !empty($instance['title']) ? esc_attr($instance['title']) : __('Custom Menu', 'zn_framework');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $menu = isset($instance['menu']) ? esc_attr($instance['menu']) : '';
     $style = isset($instance['style']) ? esc_attr($instance['style']) : '';
     $columns = isset($instance['columns']) ? esc_attr($instance['columns']) : '';
     if (empty($menu)) {
         echo 'Please edit the widget and select at least one menu';
         return;
     }
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $menu_items = wp_get_nav_menu_items($menu);
     echo '<ul class="menu-' . $menu . ' ' . $style . ' clearfix ">';
     //row
     foreach ((array) $menu_items as $key => $menu_item) {
         $title = $menu_item->title;
         $url = $menu_item->url;
         echo '<li class="' . $columns . '"><a href="' . $url . '">' . $title . '</a></li>';
     }
     echo '</ul>';
     echo $after_widget;
     // Reset the global $the_post as this query will have stomped on it
     wp_reset_postdata();
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:30,代码来源:custom_menu.php


示例3: bap_ajaxP_loop

function bap_ajaxP_loop($offset = '')
{
    global $wp_query;
    $paged = get_query_var('page') ? get_query_var('page') : 1;
    $do_not_duplicate = array();
    // OFFSET SETTING
    if (!$offset == '' || !$offset == '0') {
        $argshidepost = array('numberposts' => $offset, 'post_type' => 'post', 'post_status' => 'publish');
        $hide_to_array = get_posts($argshidepost);
        // HIDE OFFSETED POSTS
        if ($hide_to_array) {
            foreach ($hide_to_array as $post) {
                $do_not_duplicate[] = $post->ID;
            }
        }
    }
    $argsmain = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'DESC', 'post__not_in' => $do_not_duplicate);
    $wp_query = new WP_Query($argsmain);
    if ($wp_query->have_posts()) {
        echo '<section id="' . bap_get_option_text('bap_loopContainer') . '">';
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            get_template_part('partials/listitem');
        }
        echo '</section>';
    }
    wp_reset_postdata();
}
开发者ID:Aventyret,项目名称:bentoWP_plugin_AjaxPagin,代码行数:28,代码来源:bap_functions.php


示例4: rec_epl_lu_single_download

function rec_epl_lu_single_download()
{
    global $post, $epl_settings;
    $unique_id = get_post_meta($post->ID, 'property_unique_id', true);
    $tab_title = isset($epl_settings['epl_lu_group_title']) ? __($epl_settings['epl_lu_group_title'], 'epl') : __('Extra Info', 'epl');
    $query = new WP_Query(array('post_type' => 'listing_unlimited', 'meta_query' => array(array('key' => 'property_unique_id', 'value' => $unique_id, 'compare' => '=='))));
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $link = get_post_meta($post->ID, 'listing_unlimited_pdf', true);
            ?>

			<div style="xxxdisplay:none" class="rec-panel-section-32 xxxfancybox-hidden">
				<div id="xxxfancyboxID-section-32">
					<?php 
            echo do_shortcode('[gravityform id="21" title="false" description="false" tabindex="33"]');
            ?>
				</div>
			</div>
			<!--<h5 class="widget-sub-title download"><a href="#fancyboxID-section-32" class="rec-panel-section-32-popout-fancybox fancybox"><i class="fa fa-file-pdf-o"></i> Download Section 32</a></h5>-->

			<?php 
        }
    }
    wp_reset_postdata();
}
开发者ID:easypropertylistings,项目名称:library,代码行数:26,代码来源:template-functions-ash.php


示例5: ebor_testimonial_shortcode

/**
 * The Shortcode
 */
function ebor_testimonial_shortcode($atts)
{
    extract(shortcode_atts(array('pppage' => '999', 'filter' => 'all', 'type' => 'carousel-3col'), $atts));
    /**
     * Initial query args
     */
    $query_args = array('post_type' => 'testimonial', 'posts_per_page' => $pppage);
    if (!($filter == 'all')) {
        if (function_exists('icl_object_id')) {
            $filter = (int) icl_object_id($filter, 'testimonial_category', true);
        }
        $query_args['tax_query'] = array(array('taxonomy' => 'testimonial_category', 'field' => 'id', 'terms' => $filter));
    }
    /**
     * Finally, here's the query.
     */
    global $wp_query;
    $wp_query = new WP_Query($query_args);
    ob_start();
    get_template_part('loop/loop-testimonial', $type);
    wp_reset_postdata();
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:28,代码来源:vc_testimonial_block.php


示例6: widget

    function widget($args, $instance)
    {
        $cache = wp_cache_get('widget_dt_slider', 'widget');
        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 = apply_filters('widget_title', empty($instance['title']) ? __('', 'engine') : $instance['title'], $instance, $this->id_base);
        $category = empty($instance['category']) ? '' : $instance['category'];
        $qty = empty($instance['qty']) ? '3' : $instance['qty'];
        $excerpt_length = empty($instance['excerpt_length']) ? '0' : $instance['excerpt_length'];
        $r = new WP_Query(array('posts_per_page' => $qty, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'category__in' => explode(',', $category)));
        if ($r->have_posts()) {
            ?>
		<?php 
            echo $before_widget;
            echo do_shortcode('[engine_slider title="' . $title . '" category="' . $category . '" qty="' . $qty . '" autoplay="0" random="0" thumb_size="small" excerpt_length="' . $excerpt_length . '"]');
            echo $after_widget;
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('widget_dt_slider', $cache, 'widget');
    }
开发者ID:wangshijun101,项目名称:morketing.cn,代码行数:32,代码来源:dt-slider.php


示例7: widget

 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1;
     $termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand');
     if ($group = $instance['group']) {
         $termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group));
     }
     $terms = get_posts($termargs);
     if ($terms && count($terms)) {
         echo '<ul class="wpglossary widget-list">';
         foreach ($terms as $term) {
             setup_postdata($term);
             $title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>';
             $desc = '';
             $display = $instance['display'];
             if ($display && $display != 'title') {
                 $desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt());
                 $desc = '<br>' . $desc;
             }
             echo '<li>' . $title . $desc . '</li>';
         }
         wp_reset_postdata();
         echo '</ul>';
     } else {
         echo '<em>' . __('No terms available', 'wp-glossary') . '</em>';
     }
     echo $after_widget;
 }
开发者ID:s3rgiosan,项目名称:WP-Glossary,代码行数:34,代码来源:wpg-widget-random-term.class.php


示例8: load_more_posts_callback

function load_more_posts_callback()
{
    check_ajax_referer('pan_travel_blog', 'token');
    try {
        $offset = $_POST['offset'];
        $number = $_POST['number'];
        $loop = new WP_Query(array('post_type' => 'travel_blogs', 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'travel_blog_start_date', 'offset' => $offset, 'posts_per_page' => $number));
        if ($loop->have_posts()) {
            while ($loop->have_posts()) {
                $loop->the_post();
                ?>
				<?php 
                get_template_part('parts/content', 'travelblog');
                ?>
			<?php 
            }
        } else {
            ?>
			<p><?php 
            _e('Sorry, no posts matched your criteria.');
            ?>
</p>
		<?php 
        }
        wp_reset_postdata();
    } catch (Exception $e) {
        echo 'Errors';
    }
    wp_die();
}
开发者ID:spiderPan,项目名称:PanBlog,代码行数:30,代码来源:custom-ajax-handler.php


示例9: widget

    public function widget($args, $instance)
    {
        ?>
			<?php 
        echo $args['before_widget'];
        ?>
			<?php 
        echo $args['before_title'];
        echo $instance['title'];
        echo $args['after_title'];
        ?>
            <div class="list-group">
			<?php 
        $arg = array('posts_per_page' => 5, 'post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC');
        $newposts = new WP_Query($arg);
        while ($newposts->have_posts()) {
            $newposts->the_post();
            ?>
			  <a class="list-group-item" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
			<?php 
        }
        wp_reset_postdata();
        ?>
			</div>
            <?php 
        echo $args['after_widget'];
        ?>
        <?php 
    }
开发者ID:TailoredMarketing,项目名称:uPrint,代码行数:35,代码来源:widgets.php


示例10: estimate_embed

 public static function estimate_embed($atts = array())
 {
     do_action('sprout_invoices_estimate_embed');
     $estimate_id = 0;
     // Make sure id given is for an invoice
     if (isset($atts['id'])) {
         $estimate_id = (int) $atts['id'];
     }
     if (isset($_GET['si_id'])) {
         $estimate_id = (int) $_GET['si_id'];
     }
     if (SI_Estimate::POST_TYPE !== get_post_type($estimate_id)) {
         return;
     }
     // enqueue style
     self::frontend_enqueue();
     // Show snippet view or not.
     $embed_view = '';
     if (isset($atts['snippet']) && 'true' === $atts['snippet']) {
         $embed_view = '-snippet';
     }
     self::remove_actions();
     // Setup global post for filters and functions to work
     global $post;
     $post = get_post($estimate_id);
     setup_postdata($post);
     $estimate = SI_Estimate::get_instance($estimate_id);
     $line_items = $estimate->get_line_items();
     $view = self::load_addon_view_to_string('estimates/embed' . $embed_view, array('id' => $estimate_id, 'line_items' => $line_items, 'prev_type' => '', 'totals' => SI_Line_Items::line_item_totals($estimate_id)), false);
     // reset to the original post
     wp_reset_postdata();
     return $view;
 }
开发者ID:danielbachhuber,项目名称:marcgratch.com,代码行数:33,代码来源:Embeds.php


示例11: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     echo $args['before_widget'];
     $display_title = !empty($instance['display_title']) ? $instance['display_title'] : '';
     $numberofposts = !empty($instance['numberofposts']) ? absint($instance['numberofposts']) : '';
     if ($display_title == 'on') {
         if (!empty($instance['title'])) {
             echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
         }
     }
     $post_query_args = array('post_type' => array('post'), 'pagination' => false, 'posts_per_page' => $numberofposts, 'ignore_sticky_posts' => true, 'cache_results' => true, 'update_post_meta_cache' => true, 'update_post_term_cache' => true);
     $post_query = new WP_Query($post_query_args);
     if ($post_query->have_posts()) {
         while ($post_query->have_posts()) {
             $post_query->the_post();
             global $post;
             $output = '';
             $output .= '<div class="widget-recent-post clearfix">';
             $output .= has_post_thumbnail($post->ID) ? '<div class="recent-post-image">' : '';
             $output .= has_post_thumbnail($post->ID) ? get_the_post_thumbnail($post->ID, 'illdy-widget-recent-posts') : '';
             $output .= has_post_thumbnail($post->ID) ? '</div><!--/.recent-post-image-->' : '';
             $output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . esc_attr(get_the_title()) . '" class="recent-post-title">' . esc_html(get_the_title()) . '</a>';
             $output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . __('More...', 'illdy') . '" class="recent-post-button">' . __('More...', 'illdy') . '</a>';
             $output .= '</div><!--/.widget-recent-post.clearfix-->';
             echo $output;
         }
     } else {
         echo __('No posts found.', 'illdy');
     }
     wp_reset_postdata();
     echo $args['after_widget'];
 }
开发者ID:robertoperata,项目名称:bbqverona.com,代码行数:40,代码来源:class-widget-recent-posts.php


示例12: widget

 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 public function widget($args, $instance)
 {
     global $comments, $comment, $woocommerce;
     if ($this->get_cached_widget($args)) {
         return;
     }
     ob_start();
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $number = absint($instance['number']);
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand');
     $query_args['meta_query'] = array();
     $query_args['meta_query'][] = WC()->query->stock_status_meta_query();
     $query_args['meta_query'] = array_filter($query_args['meta_query']);
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo '<ul class="product_list_widget">';
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php');
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
 }
开发者ID:k2jysy,项目名称:mergeshop,代码行数:41,代码来源:widget-recent-reviews.php


示例13: td_events_api

function td_events_api()
{
    $events = array();
    $start = isset($_GET['start']) ? $_GET['start'] : '';
    $end = isset($_GET['end']) ? $_GET['end'] : '';
    $args = array('post_type' => 'event');
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $parent = get_post(get_post_meta(get_the_ID(), 'tdec_product', true));
            $dates = get_post_meta(get_the_ID(), 'tdec_dates', true);
            $color = get_post_meta(get_the_ID(), 'tdec_color', true);
            if (is_array($dates)) {
                foreach ($dates as $date) {
                    $event = array('title' => $parent->post_title, 'start' => date('c', $date['start']), 'end' => date('c', $date['end']), 'url' => get_permalink($parent->ID), 'backgroundColor' => $color);
                    $events[] = $event;
                }
            }
        }
    }
    wp_reset_postdata();
    echo json_encode($events);
    die;
}
开发者ID:NumanAfifi,项目名称:wp-demo,代码行数:25,代码来源:woocalendar.php


示例14: pmxi_findDuplicates

/**
 * Find duplicates according to settings
 */
function pmxi_findDuplicates($articleData, $custom_duplicate_name = '', $custom_duplicate_value = '', $duplicate_indicator = 'title')
{
    global $wpdb;
    if ('custom field' == $duplicate_indicator) {
        $duplicate_ids = array();
        if (!empty($articleData['post_type'])) {
            $post_types = (class_exists('PMWI_Plugin') and $articleData['post_type'] == 'product') ? array('product', 'product_variation') : array($articleData['post_type']);
            $args = array('post_type' => $post_types, 'post_status' => array('any'), 'meta_query' => array(array('key' => trim($custom_duplicate_name), 'value' => htmlspecialchars(trim($custom_duplicate_value)))), 'order' => 'ASC', 'orderby' => 'ID');
            $query = new WP_Query($args);
            if ($query->have_posts()) {
                $duplicate_ids[] = $query->post->ID;
            }
            wp_reset_postdata();
            if (empty($duplicate_ids)) {
                $query = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON (" . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id) WHERE 1=1 AND " . $wpdb->posts . ".post_type IN ('" . implode("','", $post_types) . "') AND (" . $wpdb->posts . ".post_status = 'publish' OR " . $wpdb->posts . ".post_status = 'future' OR " . $wpdb->posts . ".post_status = 'draft' OR " . $wpdb->posts . ".post_status = 'pending' OR " . $wpdb->posts . ".post_status = 'trash' OR " . $wpdb->posts . ".post_status = 'private') AND ( (" . $wpdb->postmeta . ".meta_key = '%s' AND CAST(" . $wpdb->postmeta . ".meta_value AS CHAR) = '%s') ) GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC LIMIT 0, 20", trim($custom_duplicate_name), htmlspecialchars(trim($custom_duplicate_value))));
                if (!empty($query)) {
                    foreach ($query as $p) {
                        $duplicate_ids[] = $p->ID;
                    }
                }
            }
        } else {
            $args = array('meta_query' => array(0 => array('key' => $custom_duplicate_name, 'value' => $custom_duplicate_value, 'compare' => '=')));
            $user_query = new WP_User_Query($args);
            if (!empty($user_query->results)) {
                foreach ($user_query->results as $user) {
                    $duplicate_ids[] = $user->ID;
                }
            } else {
                $query = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS " . $wpdb->users . ".ID FROM " . $wpdb->users . " INNER JOIN " . $wpdb->usermeta . " ON (" . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id) WHERE 1=1 AND ( (" . $wpdb->usermeta . ".meta_key = '%s' AND CAST(" . $wpdb->usermeta . ".meta_value AS CHAR) = '%s') ) GROUP BY " . $wpdb->users . ".ID ORDER BY " . $wpdb->users . ".ID ASC LIMIT 0, 20", $custom_duplicate_name, $custom_duplicate_value));
                if (!empty($query)) {
                    foreach ($query as $p) {
                        $duplicate_ids[] = $p->ID;
                    }
                }
            }
        }
        return $duplicate_ids;
    } elseif ('parent' == $duplicate_indicator) {
        $field = 'post_title';
        // post_title or post_content
        return $wpdb->get_col($wpdb->prepare("\n\t\t\tSELECT ID FROM " . $wpdb->posts . "\n\t\t\tWHERE\n\t\t\t\tpost_type = %s\n\t\t\t\tAND ID != %s\n\t\t\t\tAND post_parent = %s\n\t\t\t\tAND REPLACE(REPLACE(REPLACE({$field}, ' ', ''), '\\t', ''), '\\n', '') = %s\n\t\t\t", $articleData['post_type'], isset($articleData['ID']) ? $articleData['ID'] : 0, !empty($articleData['post_parent']) ? $articleData['post_parent'] : 0, preg_replace('%[ \\t\\n]%', '', $articleData[$field])));
    } else {
        if (!empty($articleData['post_type'])) {
            $field = 'post_' . $duplicate_indicator;
            // post_title or post_content
            return $wpdb->get_col($wpdb->prepare("\n\t\t\t\tSELECT ID FROM " . $wpdb->posts . "\n\t\t\t\tWHERE\n\t\t\t\t\tpost_type = %s\n\t\t\t\t\tAND ID != %s\n\t\t\t\t\tAND REPLACE(REPLACE(REPLACE({$field}, ' ', ''), '\\t', ''), '\\n', '') = %s\n\t\t\t\t", $articleData['post_type'], isset($articleData['ID']) ? $articleData['ID'] : 0, preg_replace('%[ \\t\\n]%', '', $articleData[$field])));
        } else {
            if ($duplicate_indicator == 'title') {
                $field = 'user_login';
                $u = get_user_by('login', $articleData[$field]);
                return !empty($u) ? array($u->ID) : false;
            } else {
                $field = 'user_email';
                $u = get_user_by('email', $articleData[$field]);
                return !empty($u) ? array($u->ID) : false;
            }
        }
    }
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:63,代码来源:pmxi_findDuplicates.php


示例15: widget

    function widget($args, $instance)
    {
        extract($args);
        $title_widget = $instance['title_widget'];
        $limit = $instance['limit'];
        echo $before_widget;
        echo '<h3 class="widget-title">' . $title_widget . '</h3>';
        echo '<ul>';
        $args = array('posts_per_page' => $limit, 'post_type' => 'coupons', 'meta_key' => 'clicks', 'orderby' => 'meta_value', 'order' => 'DESC');
        $coupons = get_posts($args);
        foreach ($coupons as $coupon) {
            setup_postdata($coupon);
            ?>
                    
						<li>
							<a href="<?php 
            echo get_permalink($coupon->ID);
            ?>
"><?php 
            echo get_the_title($coupon->ID);
            ?>
 ( <?php 
            echo get_post_meta($coupon->ID, 'coupon_discount', true);
            ?>
 )</a>
						</li>
					
					<?php 
        }
        wp_reset_postdata();
        echo '</ul>';
        echo $after_widget;
    }
开发者ID:nitishmittal1990,项目名称:coupon,代码行数:33,代码来源:popular_coupons.php


示例16: widget

 function widget($args, $instance)
 {
     extract($args);
     extract($instance);
     if (empty($hide_if_empty)) {
         $hide_if_empty = false;
     }
     // Get all the upcoming events for this venue.
     $events = tribe_get_events(array('post_type' => TribeEvents::POSTTYPE, 'venue' => $venue_ID, 'posts_per_page' => $count, 'eventDisplay' => 'upcoming'), true);
     // If there are no events, and the user has set to hide if empty, don't display the widget.
     if ($hide_if_empty && !$events->have_posts()) {
         return;
     }
     $ecp = TribeEventsPro::instance();
     $tooltip_status = $ecp->recurring_info_tooltip_status();
     $ecp->disable_recurring_info_tooltip();
     echo $before_widget;
     do_action('tribe_events_venue_widget_before_the_title');
     echo $instance['title'] ? $args['before_title'] . $instance['title'] . $args['after_title'] : '';
     do_action('tribe_events_venue_widget_after_the_title');
     include TribeEventsTemplates::getTemplateHierarchy('pro/widgets/venue-widget.php');
     echo $after_widget;
     if ($tooltip_status) {
         $ecp->enable_recurring_info_tooltip();
     }
     wp_reset_postdata();
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:27,代码来源:widget-venue.class.php


示例17: 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();
 }
开发者ID:ninefinecode,项目名称:ninefinecode,代码行数:30,代码来源:widgets.php


示例18: end_el

 function end_el(&$output, $item, $depth = 0, $args = array())
 {
     if ($depth == 0 && $item->object == 'category') {
         $output .= "<div class='subcat'>";
         for ($i = 0; $i < count($item->children); $i++) {
             $child = $item->children[$i];
             $output .= "<div class='" . ($i === 0 ? 'active' : '') . "' id='mn-latest-" . $child->ID . "'>";
             //$output .="<h5>".$child->title."</h5>";
             $output .= "<ul id='mn-latest-" . $child->ID . "'>";
             if ($child->object == 'category') {
                 $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => 5, 'no_found_rows' => true, 'post_status' => 'publish', 'cat' => $child->object_id)));
                 if ($r->have_posts()) {
                     while ($r->have_posts()) {
                         $r->the_post();
                         $output .= "<li ";
                         if (has_post_thumbnail()) {
                             $output .= "class='has-thumbnail' ";
                         }
                         $output .= "><div class='subcat-thumbnail'><a href='" . get_permalink() . "' title='" . get_the_title() . "'>" . get_the_post_thumbnail(get_the_ID(), array(40, 40)) . "</a></div><div class='subcat-title'><a href='" . get_permalink() . "' title='" . get_the_title() . "'> " . get_the_title() . "</a><span> - " . dw_human_time_diff(get_the_time('U'), current_time('timestamp')) . "</span></div></li>";
                     }
                     // Reset the global $the_post as this query will have stomped on it
                     wp_reset_postdata();
                 }
             }
             $output .= "</ul>";
             $output .= "<a href='" . $child->url . "' title='" . $child->attr_title . "'>View all</a>";
             $output .= "</div>";
         }
         $output .= "</div> \n</div>\n";
     } else {
     }
     $output .= "</li>\n";
 }
开发者ID:aromis,项目名称:dw-focus,代码行数:33,代码来源:mega-menu.php


示例19: bl_posttype_shortcodes_showposts

 function bl_posttype_shortcodes_showposts($params = array())
 {
     // Pulls the paramater values passed from the shortcode options
     extract(shortcode_atts(array('post_type' => 'post', 'post_status' => 'publish', 'offset' => 0, 'posts_per_page' => ''), $params));
     // Builds the query based on the available params
     $query = new WP_Query(array('post_type' => $post_type, 'post_status' => $post_status, 'offset' => $offset, 'posts_per_page' => $posts_per_page));
     // Looks for the presence of any qualifying posts inside the defined loop
     if ($query->have_posts()) {
         // We open the post container only where specified posts are available
         $shortcodeOutput = '<div>';
         while ($query->have_posts()) {
             $query->the_post();
             // Wraps each qualifying post for output in an <article> tag with Schema data.
             $shortcodeOutput .= '<article itemscope itemtype="http://schema.org/Article">';
             $shortcodeOutput .= '<a href="' . get_the_permalink() . '">';
             $shortcodeOutput .= '<h3 itemprop="name">' . get_the_title() . '</h3>';
             $shortcodeOutput .= '</a>';
             $shortcodeOutput .= '<time itemprop="dateCreated">' . get_the_date() . '</time>';
             $shortcodeOutput .= '<em itemprop="author">' . get_the_author() . '</em>';
             $shortcodeOutput .= '<div itemprop="description">' . get_the_excerpt() . '</div>';
             $shortcodeOutput .= '<article>';
         }
         // Closes off the parent container
         $shortcodeOutput .= '</div>';
     }
     // Resets the wordpress loop
     wp_reset_postdata();
     // Returns the concatenated shortcodeOutput to the page
     return $shortcodeOutput;
 }
开发者ID:benleah,项目名称:wp-posttype-shortcodes,代码行数:30,代码来源:class.bl-posttype-shortcodes.php


示例20: wpbss_main_menu_fallback

function wpbss_main_menu_fallback()
{
    global $post;
    $args = array('post_type' => 'page', 'post_status' => 'publish', 'hierarchical' => 0);
    $pages = get_pages($args);
    //var_dump($pages);
    ?>
	<ul class="nav navbar-nav">
		<?php 
    foreach ($pages as $post) {
        setup_postdata($post);
        ?>
			<li>
				<a href="<?php 
        the_permalink();
        ?>
"><?php 
        echo $post->post_title;
        ?>
</a>
			</li>
		<?php 
    }
    wp_reset_postdata();
    ?>
	</ul>
<?php 
}
开发者ID:tanzoor,项目名称:wpbss,代码行数:28,代码来源:menu-fullwidth.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_reset_query函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_replace_in_html_tags函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap