Я показываю последнее сообщение на главной странице, но получаю сообщение об ошибке. Я не могу сохранить шорткод на домашней странице.
Я пытался отобразить текст hello
на домашней странице, и он отображается, но после добавления приведенного ниже кода он не работает.
Не могли бы вы мне помочь?
function recentPost_on_home(){
$data='<div class="row">';
$args = array(
'posts_per_page' => 5, // your 'x' goes here
'nopaging' => true
// possibly more arguments here
);
// set up new query
$tyler_query = new WP_Query( $args );
// loop through found posts
if ($tyler_query->have_posts()) {
while ( $tyler_query->have_posts() ) {
$tyler_query->the_post();
$data.= '<div class="swiper-slide">
<div class="cs-post-item">
<div class="cs-post-category-icon">
<a href="'.the_permalink().'"></a>
</div>
<div class="cs-post-thumb">
<a href="'.the_permalink().'"><img src="'.the_post_thumbnail_url().'" alt="'.the_title().'"></a>
</div>
<div class="cs-post-inner">
<h3><a href="'.the_permalink().'">'.the_title().'</a></h3>
</div>
</div>';
}
}
$data.='</div>';
return $data;
}
add_shortcode( 'home_recent_post', 'recentPost_on_home' );