(98.0, 14.0)
勤務地表記確認
(230.0, 19.0)
ケイサイカキンなしんこうぃあ 02
答案 0 :(得分:1)
两件事:
1。 如果你必须使用你正在尝试的代码,顺便说一下这不是最好的方法,那就看#2点。您在当前代码中看到,您在循环迭代中覆盖了您的PHP变量,因此每次都会重置它,这就是为什么您只获得最后的后期值/数据,以修复此更改:
$output = '<\a href="'. get_the_permalink().'">
到
$output.= '<a href="'. get_the_permalink().'">
查看=
符号前的点。
2。 为了更好的代码我建议使用这样的东西:
function who_we_work_with(){
$debut = 0; //The first article to be displayed
$args = array(
'post_type' => 'post',
'posts_per_page' => 4,
'no-paging' => true,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
if (has_post_thumbnail( get_the_ID() ) ){
$image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' );
$output.='<a href="'. get_the_permalink().'">
<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 padding_right0 csr_activities_news" style="background:url(' .$image[0].');background-size:cover;">';
$output.= get_the_title();
}
$output.='<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 csr_news"></div></div></a>';
endwhile;
endif;
wp_reset_postdata();
return $output;
}