我已经编写了我的第一个插件。目的是展示前6篇文章的图片、标题和摘录。(它使用Divi中的函数,这里和那里)。
function jm_blog_layout($atts) {
ob_start();
echo \'<div class="featured-posts">\';
query_posts(array(\'category_name\' => "", \'posts_per_page\' => "6"));
$post_index = 0;
while (have_posts()) : the_post();
$thumbnail_image = get_thumbnail($width = 333)["thumb"];
$post_id = get_the_id();
$post_class = \'featured-post\';
if ($post_index == 3) {
$post_class = $post_class.\' focus-post\';
}
echo \'<a href="\'.get_permalink().\'">\';
echo \'<div class="\'.$post_class.\'" id="post-\'.$post_id.\'"style="background-image: url(\'.$thumbnail_image.\');">\';
echo \'<div class="overlay">\';
echo \'<div class="transformable">\';
echo \'<h2 class="vertical-align">\'.get_the_title().\'</h2>\';
echo \'<h3 class="thumb-excerpt">\'.get_the_excerpt().\'</h3>\';
echo \'</div>\';
echo \'</div>\';
echo \'</div>\';
echo \'</a>\';
$post_index += 1;
endwhile;
echo \'</div>\';
$output = ob_get_contents();
ob_end_clean();
return $output;
}
它输出我想要的内容,奇怪的是,后面是我查询的6篇帖子的所有内容(即正文),结构如下:
<article id="post-84" class="post-84 post type-post status-publish format-standard has-post-thumbnail hentry category-tips">
<div class="entry-content">
<p>...</p>
</div> <!-- .entry-content -->
</article>
它不是我的页面设计的一部分,也不是我的代码。它可能来自哪里?