1
我试图从我的网站的/ blog目录的HTML/CSS首页添加3个最近的博客文章。到目前为止它可行,但我遇到了问题;只要文章中的摘录限制较低,就不会显示“继续阅读”。我想知道是否可以通过首页上的PHP改变摘录限制。最近的WordPress的首页(HTML)文章
下面是当前的代码PHP:
<div class="ro-section ro-padding-top">
<h3 class="ro-hr-heading">Our Latest Blog Articles</h3>
<div class="container">
<?php
include('blog/wp-load.php');
$args = array('showposts' => 6);
$the_query = new WP_Query($args);
echo '<div class="row">';
if($the_query->have_posts()):
while ($the_query->have_posts()) : $the_query->the_post();
echo '<div class="col-md-4">
<h4 class="ro-service-item-4">'.get_the_title().'</h4>
<a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a>
'.get_the_excerpt($limit).'</p></div>';
endwhile;
endif;
echo '</div>';
wp_reset_query();
?>
</div>
</div>
简短的回答:**是**。长的回答:你是否曾经使用过这个? Google“WordPress WP_Query”,看看你找到了什么。 –
@cale_b是的我在Google上看过。我尝试添加wpdocs_custom_excerpt_length,但不知道如何完全实现它。仍在学习PHP。 – Emanuel
向我们展示您为自定义摘录试用的代码 – FluffyKitten