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


PHP wp_query::the_post方法代码示例

本文整理汇总了PHP中wp_query::the_post方法的典型用法代码示例。如果您正苦于以下问题:PHP wp_query::the_post方法的具体用法?PHP wp_query::the_post怎么用?PHP wp_query::the_post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wp_query的用法示例。


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

示例1: home_banners_func

function home_banners_func($atts, $content = null)
{
    // New function parameter $content is added!
    extract(shortcode_atts(array('width' => '1/2', 'el_position' => '', 'section_height' => '', 'loop' => '', 'slideshow' => '', 'time' => '', 'transition_time' => ''), $atts));
    $output = '';
    global $post;
    // get recent posts
    $args = array('post_type' => 'banner', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'caller_get_posts' => 1);
    $posts = new wp_query($args);
    // if posts exist
    if ($posts->have_posts()) {
        $output .= '<section class="flexslider std-slider" data-height="' . $section_height . '" data-loop="' . $loop . '" data-smooth="false" data-slideshow="' . $slideshow . '" data-speed="' . $time . '" data-animspeed="' . $transition_time . '" data-controls="true" data-dircontrols="true">';
        $output .= '<ul class="slides">';
        // loop through and display them
        while ($posts->have_posts()) {
            $posts->the_post();
            if (rwmb_meta('_wp_banner_image', $post->ID)) {
                $images = rwmb_meta('_wp_banner_image', 'type=plupload_image', $post->ID);
                if (count($images) > 0) {
                    foreach ($images as $image) {
                        $image_url = wp_get_attachment_image_src($image['ID'], 'full');
                        $output .= '<li data-bg="' . $image_url[0] . '">';
                    }
                }
            }
            $output .= '<div class="container">';
            $output .= '<div class="inner">';
            $output .= '<div class="row">';
            $output .= '<div class="text-center animated" data-fx="fadeIn">';
            if (rwmb_meta('_wp_title', get_the_ID())) {
                $output .= '<h2>' . rwmb_meta('_wp_title', get_the_ID()) . '</h2>';
            }
            if (rwmb_meta('_wp_sub_title', get_the_ID())) {
                $output .= '<p>' . rwmb_meta('_wp_sub_title', get_the_ID()) . '</p>';
            }
            if (rwmb_meta('_wp_show_button_1', get_the_ID()) == 1) {
                $output .= '<a href="' . rwmb_meta('_wp_button_1_url', get_the_ID()) . '" class="btn btn-primary btn-lg local">' . rwmb_meta('_wp_button_1_text', get_the_ID()) . '</a>';
            }
            if (rwmb_meta('_wp_show_button_2', get_the_ID()) == 1) {
                $output .= '<a href="' . rwmb_meta('_wp_button_2_url', get_the_ID()) . '" class="btn btn-default btn-lg">' . rwmb_meta('_wp_button_2_text', get_the_ID()) . '</a>';
            }
            $output .= '</div>';
            $output .= '<div class="col-md-6"></div>';
            $output .= '</div>';
            $output .= '</div>';
            $output .= '</div>';
            $output .= '</li>';
        }
        $output .= '</ul>';
        $output .= '</section>';
    }
    wp_reset_query();
    return $output;
}
开发者ID:Kafia,项目名称:Mark-WordPress-Theme-,代码行数:54,代码来源:home-banners.php

示例2: extract

 function custom_query($atts)
 {
     extract(shortcode_atts(array('query_string' => ''), $atts));
     $result = '';
     global $post;
     $query = new wp_query($query_string);
     if ($query->have_posts()) {
         while ($query->have_posts()) {
             $query->the_post();
             $meta = get_post_meta($post->ID, 'thumbnail', true);
             $result .= "<div class='post-item'>\n\t\t\t\t\t\t\t<a href=" . get_permalink() . "><img width='100' height='100' src=" . $meta . " /></a>\n\t\t\t\t\t\t\t<h1><a href=" . get_permalink() . ">" . get_the_title() . "</a></h1>\n\t\t\t\t\t\t\t<p class='metadata'><span class='post'>Posted by:</span>" . get_the_author() . "<span class='in-cat'>In:</span>" . get_the_category_list(', ') . "<span class='on-date'>On:</span>" . get_comment_time() . "<a href=" . get_comments_link() . ">" . get_comments_number('1 comment', '2 comment', '% comment') . "</a></p>\n\t\t\t\t\t\t\t<p>" . get_the_content() . "</p>\n\t\t\t\t\t\t\t<p><a class='more-link floatright' href=" . get_permalink() . ">Read More</a></p>\n\t\t\t\t\t\t</div>";
         }
     }
     return $result;
 }
开发者ID:mynein,项目名称:myne,代码行数:15,代码来源:custom_query.php

示例3: array

 /**
  * Show the most recent posts
  */
 function mbdmaster_latest_posts()
 {
     global $post;
     $orig_post = $post;
     $args = array('posts_per_page' => 3, 'ignore_sticky_posts' => 1);
     $my_query = new wp_query($args);
     if ($my_query->have_posts()) {
         while ($my_query->have_posts()) {
             $my_query->the_post();
             get_template_part('content', 'archive');
         }
         $post = $orig_post;
         wp_reset_query();
     }
 }
开发者ID:markbaindesign,项目名称:mbd-wp-theme,代码行数:18,代码来源:latest-posts.php

示例4: recent_projects_func

function recent_projects_func($atts, $content = null)
{
    // New function parameter $content is added!
    extract(shortcode_atts(array('width' => '1/2', 'el_position' => '', 'number' => ''), $atts));
    $output = '';
    global $post;
    // get recent posts
    $args = array('post_type' => 'portfolio', 'posts_per_page' => $number, 'caller_get_posts' => 1);
    $portfolio_items = new wp_query($args);
    // if posts exist
    if ($portfolio_items->have_posts()) {
        $output .= '<div id="galleryContainer" class="clearfix">';
        // loop through and display them
        while ($portfolio_items->have_posts()) {
            $portfolio_items->the_post();
            // find and display categories of portfolio items
            $categories = get_the_terms(get_the_ID(), 'portfolio-category');
            if ($categories && !is_wp_error($categories)) {
                $cat_list = array();
                $cat_list_slug = array();
                foreach ($categories as $category) {
                    $cat_list[] = $category->name;
                    $cat_list_slug[] = $category->slug;
                }
                $types = join(" ", $cat_list_slug);
                $types_comma = join(", ", $cat_list);
            }
            if (has_post_thumbnail()) {
                $output .= '<div class="galleryItem ' . $types . '">';
                $output .= '<a href="' . get_the_permalink() . '" class="area-hover">';
                $output .= '<div class="vertical-parent">';
                $output .= '<div class="vertical-child">';
                $output .= '<span class="cat-links">' . $types_comma . '</span>';
                $output .= '<h4 class="entry-title">' . get_the_title() . '</h4>';
                $output .= '</div>';
                $output .= '</div>';
                $output .= '</a>';
                $output .= '<a href="' . get_the_permalink() . '">' . get_the_post_thumbnail(get_the_ID(), 'related') . '</a>';
                $output .= '</div>';
            }
        }
        $output .= '</div>';
    }
    wp_reset_query();
    return $output;
}
开发者ID:Kafia,项目名称:Mark-WordPress-Theme-,代码行数:46,代码来源:recent-projects.php

示例5: extract

    function ticker_function($atts, $content)
    {
        extract(shortcode_atts(array('style' => 'left'), $atts));
        ?>
		<div class="wd_sticker">
			<?php 
        ob_start();
        ?>
			<?php 
        $ticker = new wp_query(array('meta_key' => THEME_SLUG . 'showbreakingnews', 'ignore_sticky_posts' => 1, 'meta_value' => 1));
        ?>
			<?php 
        if ($ticker->have_posts()) {
            ?>
				<ul id="js-news" class="js-hidden">
					<?php 
            while ($ticker->have_posts()) {
                $ticker->the_post();
                global $post;
                ?>
	
								<li class="news-item"><?php 
                the_title();
                ?>
 <a href="<?php 
                the_permalink();
                ?>
"><?php 
                _e('view more', 'wpdance');
                ?>
</a></li>
					<?php 
            }
            ?>
				</ul>
			<?php 
        }
        $result = ob_get_contents();
        ob_end_clean();
        wp_reset_postdata();
        ?>
		</div>
		<?php 
        return $result;
    }
开发者ID:mynein,项目名称:myne,代码行数:45,代码来源:ticker.php

示例6: array

 /**
  * Show a set of related posts based on tags
  */
 function mbdmaster_related_posts()
 {
     global $post;
     $orig_post = $post;
     $custom_taxterms = wp_get_object_terms($post->ID, 'post_tag', array('fields' => 'ids'));
     $args = array('post_type' => array('award', 'book', 'interview', 'project', 'post', 'talk', 'film'), 'post__not_in' => array($post->ID), 'posts_per_page' => 3, 'ignore_sticky_posts' => 1, 'tax_query' => array(array('taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $custom_taxterms)));
     $my_query = new wp_query($args);
     if ($my_query->have_posts()) {
         while ($my_query->have_posts()) {
             $my_query->the_post();
             get_template_part('content', 'archive');
         }
         $post = $orig_post;
         wp_reset_query();
     } else {
         echo 'Nothing found... Looks like this post is just unique :)';
     }
 }
开发者ID:markbaindesign,项目名称:mbd-wp-theme,代码行数:21,代码来源:related-posts.php

示例7: array

 /**
  * Show a set of related posts based on a custom taxonomy
  */
 function mbdmaster_related_custom_posts()
 {
     global $post;
     $orig_post = $post;
     $custom_taxterms = wp_get_object_terms($post->ID, 'tag', array('fields' => 'ids'));
     $args = array('post_type' => 'work', 'post_status' => 'publish', 'posts_per_page' => 3, 'orderby' => 'rand', 'tax_query' => array(array('taxonomy' => 'tag', 'field' => 'id', 'terms' => $custom_taxterms)), 'post__not_in' => array($post->ID));
     $my_query = new wp_query($args);
     if ($my_query->have_posts()) {
         while ($my_query->have_posts()) {
             $my_query->the_post();
             get_template_part('content', 'archive');
         }
         $post = $orig_post;
         wp_reset_query();
     } else {
         _e('Sorry, but there is no related work at this time.', '_mbdmaster');
     }
 }
开发者ID:markbaindesign,项目名称:mbd-wp-theme,代码行数:21,代码来源:related-custom-posts.php

示例8: array

 function sidebars_remove($sidebar_id, $default_id = null)
 {
     global $post;
     $data_return = array();
     $wp_query_pages = new wp_query(array('showposts' => -1, 'post_type' => 'page'));
     while ($wp_query_pages->have_posts()) {
         $wp_query_pages->the_post();
         $page_custom_meta = get_post_custom($post->ID);
         if (is_array($page_custom_meta) && array_key_exists('_ewf-page-sidebar', $page_custom_meta)) {
             if ($page_custom_meta["_ewf-page-sidebar"][0] == $sidebar_id) {
                 $data_return[$post->ID] = "true";
                 update_post_meta($post->ID, "_ewf-page-sidebar", $default_id);
             } else {
                 $data_return[$post->ID] = "false";
             }
         }
     }
     wp_reset_postdata();
     return $data_return;
 }
开发者ID:kadr,项目名称:semashko,代码行数:20,代码来源:ewf-modLayout.php

示例9: agatha_postsrelacionados

function agatha_postsrelacionados()
{
    $orig_post = $post;
    global $post;
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
        $tag_ids = array();
        foreach ($tags as $individual_tag) {
            $tag_ids[] = $individual_tag->term_id;
        }
        $args = array('tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'posts_per_page' => 4, 'caller_get_posts' => 1);
        $my_query = new wp_query($args);
        ?>
    <section id="relatedPost">
        <?php 
        while ($my_query->have_posts()) {
            $my_query->the_post();
            ?>
        <div class="col-md-3 col-xs-6 relatedPost">
            <a rel="external" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_post_thumbnail('miniatura');
            ?>
<br />
            <?php 
            the_title();
            ?>
            </a>
        </div>
        <?php 
        }
        ?>
    </section>
    <?php 
    }
    $post = $orig_post;
    wp_reset_query();
}
开发者ID:ericsoncardosoweb,项目名称:agatha-wp,代码行数:40,代码来源:post-relacionados.php

示例10: widget

    public function widget($args, $instance)
    {
        $javo_wg_testimonial_posts_args = array('post_type' => 'jv_testimonials', 'post_status' => 'publish', 'posts_per_page' => 3);
        $javo_wg_testimonial_posts = new wp_query($javo_wg_testimonial_posts_args);
        ?>

		<div class='row'>
			<div class='col-md-12'>
				<div class="carousel slide" data-ride="carousel" id="javo_wg_testimonial">
				<!-- Carousel Slides / Quotes -->
				<div class="carousel-inner">
				<?php 
        if ($javo_wg_testimonial_posts->have_posts()) {
            $i = 0;
            while ($javo_wg_testimonial_posts->have_posts()) {
                $i++;
                $javo_wg_testimonial_posts->the_post();
                ?>
						<div class="item<?php 
                echo $i == 1 ? ' active' : '';
                ?>
">
						<div class="row">
						<div class="col-sm-12">
						<p><?php 
                the_content();
                ?>
</p>
						</div>
						</div>
						<div class="row">
						<div class="col-sm-6 text-center">
						<?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail(array(80, 80), array('class' => 'img-circle javo_wg_testimonial-featured'));
                }
                ?>
						</div>
						<div class="col-sm-6">
						<h3><?php 
                printf('%s %s', get_the_author_meta('first_name'), get_the_author_meta('last_name'));
                ?>
</h3>
						</div>
						</div>
						</div>
					<?php 
            }
            // End While
        }
        // End If
        ?>
				</div>
				<!-- Carousel Buttons Next/Prev -->
				<a data-slide="prev" href="#javo_wg_testimonial" class="left carousel-control hidden-xs"><i class="fa fa-chevron-left"></i></a>
				<a data-slide="next" href="#javo_wg_testimonial" class="right carousel-control hidden-xs"><i class="fa fa-chevron-right"></i></a>
				<!-- Bottom Carousel Indicators -->
				<ol class="carousel-indicators">
				<li data-target="#javo_wg_testimonial" data-slide-to="0" class="active"></li>
				<li data-target="#javo_wg_testimonial" data-slide-to="1"></li>
				<li data-target="#javo_wg_testimonial" data-slide-to="2"></li>
				</ol>
				</div>
			</div><!-- 12 Columns Close -->
		</div><!-- Row Close -->

	<?php 
        wp_reset_query();
    }
开发者ID:redcypress,项目名称:lacecake,代码行数:69,代码来源:wg-javo-testimonial-slide.php

示例11: array

    function redwaves_related_posts()
    {
        $related_posts = get_theme_mod('related_posts', '1');
        $related_posts_number = get_theme_mod('related_posts_number', '4');
        $related_posts_query = get_theme_mod('related_posts_query', 'tags');
        if ($related_posts && intval($related_posts_number) > 0 && intval($related_posts_number) <= 6) {
            if ($related_posts_query && $related_posts_query === 'tags') {
                global $post;
                $orig_post = $post;
                $tags = wp_get_post_tags($post->ID);
                if ($tags) {
                    $tag_ids = array();
                    foreach ($tags as $individual_tag) {
                        $tag_ids[] = $individual_tag->term_id;
                    }
                    $args = array('tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'posts_per_page' => $related_posts_number, 'ignore_sticky_posts' => 1, 'orderby' => 'rand');
                    $my_query = new wp_query($args);
                    if ($my_query->have_posts()) {
                        echo '<div id="related_posts" class="related-posts"><h3>' . esc_attr_e('Related Posts', 'redwaves-lite') . '</h3><ul>';
                        while ($my_query->have_posts()) {
                            $my_query->the_post();
                            ?>
				<?php 
                            if (has_post_thumbnail()) {
                                ?>
				<li><div class="horizontal-container"><div class="relatedthumb"><a href="<?php 
                                the_permalink();
                                ?>
" rel="bookmark" title="<?php 
                                the_title_attribute();
                                ?>
"><?php 
                                the_post_thumbnail('small');
                                ?>
</a></div>
				<div class="post-data-container"><div class="post-title"><?php 
                                the_title();
                                ?>
</div><div class="post-info"><div class="meta-info">
				<?php 
                                redwaves_posted();
                                redwaves_entry_comments();
                                ?>
				</div></div></div></div></li>
				<?php 
                            } else {
                                ?>
				<li><div class="horizontal-container">
				<div class="relatedthumb">
				<a href="<?php 
                                the_permalink();
                                ?>
" rel="bookmark" title="<?php 
                                the_title_attribute();
                                ?>
">
				<img src="<?php 
                                echo get_template_directory_uri();
                                ?>
/images/nothumb-120x120.png" width="120" height="120" alt="<?php 
                                the_title_attribute();
                                ?>
" />
				</a>
				</div>
				<div class="post-data"><div class="post-data-container">
				<div class="post-title"><?php 
                                the_title();
                                ?>
</div>
				<div class="post-info"><div class="meta-info">
				<?php 
                                redwaves_posted();
                                redwaves_entry_comments();
                                ?>
				</div></div>
				</div></div>
				</div></li>
				<?php 
                            }
                            ?>
				<?php 
                        }
                        echo '</ul></div>';
                    }
                }
                $post = $orig_post;
                wp_reset_query();
            } else {
                global $post;
                $orig_post = $post;
                $categories = get_the_category($post->ID);
                if ($categories) {
                    $category_ids = array();
                    foreach ($categories as $individual_category) {
                        $category_ids[] = $individual_category->term_id;
                    }
                    $args = array('category__in' => $category_ids, 'post__not_in' => array($post->ID), 'posts_per_page' => $related_posts_number, 'ignore_sticky_posts' => 1, 'orderby' => 'rand');
                    $my_query = new wp_query($args);
                    if ($my_query->have_posts()) {
//.........这里部分代码省略.........
开发者ID:sawan34,项目名称:tanzi,代码行数:101,代码来源:functions.php

示例12: ratings

    public function ratings($all = FALSE, $count = -1, $view_type = 'normal', $length = 0)
    {
        global $javo_tso, $javo_custom_item_label;
        $javo_this_args = array("post_type" => "ratings", "post_status" => "publish", 'posts_per_page' => $count, "meta_query" => array(array("key" => "rating_parent_post_id", "compare" => "=", "type" => "NUMBERIC", "value" => $this->post->ID)));
        if ($all) {
            unset($javo_this_args['meta_query']);
        }
        $javo_rating_posts = new wp_query($javo_this_args);
        ob_start();
        ?>
		<div class="javo-rat-area row">
			<div class="col-md-12">
			<?php 
        if ($javo_rating_posts->have_posts()) {
            while ($javo_rating_posts->have_posts()) {
                $javo_rating_posts->the_post();
                $this->user_average_score = get_post_meta(get_the_ID(), 'rating_average', true);
                $this->parent_post_id = get_post_meta(get_the_ID(), 'rating_parent_post_id', true);
                $this->parent_post = get_post($this->parent_post_id);
                switch ($view_type) {
                    // Shortcode Display Type
                    case 'tab':
                        ?>
						<div class="row rating-wrap">
							<div class="col-md-12">
								<div class="row">
									<div class="col-md-5">
										<div class="rating-author pull-left">
											<?php 
                        if (get_the_author_meta('avatar')) {
                            echo wp_get_attachment_image(get_the_author_meta('avatar'), 'javo-tiny', 1, array('class' => 'img-circle'));
                        } else {
                            printf('<img src="%s" class="img-responsive wp-post-image img-circle" style="width:80px; height:80px;">', $javo_tso->get('no_image', JAVO_IMG_DIR . '/no-image.png'));
                        }
                        ?>

											<div class="rating-total"><?php 
                        printf('%.1f', get_post_meta(get_the_ID(), 'rating_average', true));
                        ?>
</div> <!-- rating-total -->
										</div> <!-- rating-author -->

										<div class="rating-each-details pull-left">
											<?php 
                        echo apply_filters('javo_rating_score_display', get_the_ID(), false);
                        ?>
											<!-- javo-rating-registed-score -->
										</div> <!-- rating-each-details -->
									</div>
									<div class="rating-comments pull-left">
										<a href="<?php 
                        echo get_permalink($this->parent_post_id);
                        ?>
#item-ratings"><span><?php 
                        printf('%s %s', get_the_author_meta('first_name'), get_the_author_meta('last_name'));
                        ?>
 : </span>
											<?php 
                        if ((int) $length > 0) {
                            echo javo_str_cut(strip_tags(get_the_content()), $length);
                        } else {
                            echo strip_tags(get_the_content());
                        }
                        ?>
										</a>
									</div> <!-- rating-comments -->
								</div>
								<div class="clearfix"></div>

							</div> <!-- col-md-12 -->
						</div>

						<?php 
                        break;
                    case 'detail':
                        ?>
						<ul class="list-group">
							<li class="list-group-item">
								<div class="row">
									<div class="col-md-2 text-center">
										<div><?php 
                        echo wp_get_attachment_image(get_the_author_meta('avatar'), 'javo-tiny', 1, array('class' => 'img-circle'));
                        ?>
 </div>
									</div>
									<div class="col-md-5">
										<?php 
                        echo apply_filters('javo_rating_score_display', get_the_ID());
                        ?>
									</div>
									<div class="col-md-5">
										<a href="<?php 
                        echo get_permalink($this->parent_post->ID);
                        ?>
#item-ratings">
											<h3><?php 
                        echo $this->parent_post->post_title;
                        ?>
</h3>
											<p><?php 
//.........这里部分代码省略.........
开发者ID:kaiifalcutela,项目名称:eatdk,代码行数:101,代码来源:javo-ratings.php

示例13: get_field

echo get_field('category_subtitle_policy');
?>
</h3>
                </div>
                <div class="col-xs-12 col-sm-10 col-sm-push-1 items-holder">
<?php 
// POLICY QUERY
$args3 = array('post_type' => 'resources', 'category__in' => 31, 'posts_per_page' => 4, 'orderby' => 'modified', 'tax_query' => array(array('taxonomy' => 'bhpn_theme', 'field' => 'id', 'terms' => '5')));
$query3 = new wp_query($args3);
$mini_args = array('post_type' => 'resources', 'tax_query' => array(array('taxonomy' => 'bhpn_theme', 'field' => 'id', 'terms' => '5')));
$mini_q = new wp_query($mini_args);
if (!$query3->have_posts()) {
    get_template_part("content", "no-content");
}
while ($query3->have_posts()) {
    $query3->the_post();
    get_template_part("content", "item-small");
}
?>
                </div>
                <?php 
if ($query3->have_posts()) {
    ?>
<div class="col-xs-12 col-sm-10 col-sm-push-1"><a href="/resources/?bhpn_theme=policy" class="orange-box">View All Resources (<?php 
    echo $mini_q->found_posts;
    ?>
)</a></div><?php 
}
wp_reset_postdata();
?>
            </div>
开发者ID:barkdesignchicago,项目名称:BHPN,代码行数:31,代码来源:content-page-resources.php

示例14: array

                    $sep = ' , ';
                }
                $fea_tags .= $sep . $theTagId->slug;
            }
            $args = array('tag' => $fea_tags, 'posts_per_page' => $number, 'no_found_rows' => 1);
        } else {
            $args = array('category__in' => $cat, 'posts_per_page' => $number, 'no_found_rows' => 1);
        }
        $breaking_query = new wp_query($args);
        if ($breaking_query->have_posts()) {
            $count = 0;
            ?>
			<ul>
		<?php 
            while ($breaking_query->have_posts()) {
                $breaking_query->the_post();
                $count++;
                ?>
			<li><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                the_title();
                ?>
</a></li>
		<?php 
            }
            $post = $original_post;
开发者ID:hongtien510,项目名称:gia_su,代码行数:31,代码来源:breaking-news.php

示例15: array

$categories = get_the_category($post->ID);
if ($categories) {
    ?>
    <hr>
    <?php 
    $category_ids = array();
    foreach ($categories as $individual_category) {
        $category_ids[] = $individual_category->term_id;
    }
    $args = array('category__in' => $category_ids, 'post__not_in' => array($post->ID), 'posts_per_page' => 2, 'ignore_sticky_posts' => 1, 'orderby' => 'rand');
    $query = new wp_query($args);
    if ($query->have_posts()) {
        $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'blog');
        echo '<div id="related-posts"><h5>You may also like</h5><ul class="nolist">';
        while ($query->have_posts()) {
            $query->the_post();
            $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'blog');
            ?>
                    <li class="one-half">
                        <h6 class="p-name entry-title">
                            <a class="u-url" href="<?php 
            the_permalink();
            ?>
">
                               	<?php 
            the_title();
            ?>
                            </a>
                        </h6>
                        <p class="p-summary entry-summary"><?php 
            echo esc_html(reza_excerpt(25));
开发者ID:shameemreza,项目名称:twentysixteenpro,代码行数:31,代码来源:post-footer.php


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