wordpress如何调用指定标签下的N条文章及文章的缩略图(调用特征图片,不是第一张图)、限定字数的内容?

目前是用函数调用指定标签的文章标题,但是不会调用文章的内容和特征图片。
是否可以使用wp自带的函数实现?
请详细解答下,多谢!

<ul>
<?php
$args=array(
'tag_id' => 10, // 标签ID,如ID = 10
'posts_per_page' => 10, // 显示篇数,如10
);
$query = new WP_Query($args);
if(have_posts()) : while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></li>
<?php endwhile; endif; wp_reset_query();?>
</ul>

可以参考官网WP Query的用法

codex.wordpress.org/Class_Reference/WP_Query

追问

这个就是调用标题,没有内容和缩略图,我现在能调用标题,可是缩略图和限定字数的内容无法调用,麻烦再帮助指点一下,非常感谢!!!

追答<?php
$args=array(
'tag_id' => 18,
'posts_per_page' => 1,
);
query_posts($args);
if(have_posts()) : while (have_posts()) : the_post();
?>
<h3><a href="<?php the_permalink() ?>"><?php the_post_thumbnail('thumb_qyjj'); ?></a></h3>
<div class="home_widget_more"><a href="<?php the_permalink() ?>" class="first" target="_blank"><?php echo mb_strimwidth(get_the_content(), 0, 100, '…'); ?></a></a>
</div>
<?php endwhile; endif; wp_reset_query();?>

用query_posts($args);这个,不用WP Query

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答