1
WordPress에서 최신 블로그 게시물을 호출하는 데 사용하는 단축 코드를 만들었습니다. 제목과 내용을 <h2>
및 <p>
으로 감쌌지만 적용되지 않았습니다. html이 생성되고 있지만 원하는 태그가 없습니다. 나는 무엇을 잘못 쓰고 있는가?WordPress의 단축 코드 문제
<?php
//blog posts shortcode
function my_recent_post()
{
global $post;
$html = "";
$my_query = new WP_Query(array(
'post_type' => 'post',
'cat' => '4',
'posts_per_page' => 1
));
if($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post();
$html .= "<span>" . the_post_thumbnail('medium', array('class' => 'img-responsive')) . "</span>";
$html .= "<h2>" . the_title() . "</h2>";
$html .= "<p>" . the_excerpt() . "</p>";
endwhile; endif;
return $html;
}
add_shortcode('blog', 'my_recent_post');
?>
을보십시오. 내 코드를 사용해 볼 수 있습니까? –