php - 在 wordpress 的主页上添加简码时更新失败
问题描述
我正在主页上显示最近的帖子,但出现错误。我无法在主页上保存简码。
我试图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' );
解决方案
推荐阅读
- swift - 当前位置和更新位置之间的距离
- python - 在 Python3.6 中使用 Numpy 创建概率分布
- scala - _spark_metadata 导致问题
- r - 以矢量化方式从列表中提取项目?
- ruby-on-rails - 如何避免 Errno::EISDIR: Is a directory - 在运行种子迁移时读取?
- sql - 用于部分更改数据点的数据库设计,具有历史记录和快照功能?
- sql - 无法使用 LISTAGG
- javascript - 如何在 AngularJS 中跨多个页面保留 window.performance.getEntries() 值?
- spring-mvc - 403 - Spring MVC 中请求映射的禁止错误
- javascript - 如何将 EJS 模板的表格列的字符串转换为 dd-mm-yyyy 格式?