大家好,我是一个中等权重的wp设计师/开发人员,在我工作的网站上遇到了问题。演示页面如下:
http://flock.simonpointer.com/blog/
我在模板文件中继承了以下循环代码,我一辈子都不明白为什么我在特色内容框中的作者信息会有两个输出。我似乎得到了第一篇和第二篇文章。在第二个页面上,不会加载作者照片和链接详细信息,但会加载到第一个页面上,并且会显示第二个页面的帖子缩略图,但不会显示第一个页面的帖子缩略图。感谢您的帮助:
<div class="col-2-5"><div class="feature-card blog-featured-card">
<?php
//$args = array( \'posts_per_page\' => 1);
$loop = new WP_Query(
array(
\'post_type\' => \'post\',
\'posts_per_page\' => 1
) );
while ( $loop->have_posts() ) : $loop->the_post();
if(isset($post->author)){
$team_id = $post->author;//get the post id of the team indiviual detail page
$author_name = get_the_title( $team_id ); //get the page title from the id
$author_image = wp_get_attachment_url(get_post_meta($team_id, \'image\', true));
$image = get_field(\'image\', $team_id);
$author_link = get_permalink($team_id);
$page_elements = array(
\'author_name\' => $author_name,
\'author_image\' => $image[\'sizes\'][\'thumbnail\'],
\'author_link\' => $author_link,
);
$author_html = \'<div class="blog-author">
<a href="\'.$page_elements[\'author_link\'].\'" title="">
<img src="\'.$page_elements[\'author_image\'].\'" alt="\'.$page_elements[\'author_name\'].\'" />
</a>
<span>By <a href="\'.$page_elements[\'author_link\'].\'">\'.$page_elements[\'author_name\'].\'</a></span>
</div>\';
}
echo \'<div class="blog-feature-go">\';
echo \'<p><a href="\'.get_permalink().\'" title="\'.get_the_title().\'">\'.get_the_post_thumbnail().\'</a></p>\';
echo \'<h2 class="test-headin"><a href="\'.get_permalink().\'" title="\'.get_the_title().\'">\'.get_the_title().\'</a></h2>\';
echo $author_html;
echo \'<div><a class="text-arrow-cta cta-button read-more-button" href="\'.get_permalink().\'" title="\'.get_the_title().\'">Read More</a></div>\';
echo \'</div>\';
endwhile;
?>