我尝试了很多东西,但我没有在link
paragraph
page.php文件
<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="inner-box-post">';
echo '<h2><a href="get_permalink();">';
the_title();
echo '</a></h2>';
echo '<div class="thumbnail">';
the_post_thumbnail( 'thumbnail' );
get_comments( $args );
echo '</div>';
echo '<div class="post-containt">';
echo '<div class="post-date"><strong>';
echo get_the_date();
echo '</strong> </div>';
echo the_excerpt(); ;
echo '</div> ';
echo '</div>';
endwhile; ?>
</div>
function.php
function new_excerpt_more($output) {
return $output . '<p><a href="'. get_permalink() . '">' . 'Read more »' . '</a></p>';
}
add_filter('get_the_excerpt', 'new_excerpt_more');
答案 0 :(得分:1)
答案 1 :(得分:1)
<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="inner-box-post">
<h2><a href="get_permalink();"><?php the_title(); ?></a></h2>
<div class="thumbnail">
<?php the_post_thumbnail( 'thumbnail' ); ?>
<?php get_comments( $args ); ?>
</div>
<div class="post-containt">
<div class="post-date">
<strong><?php echo get_the_date(); ?></strong>
</div>
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; ?>
删除[...]并使用
添加更多阅读选项function new_excerpt_more($output) {
$output = rtrim($output,'[...]');
return $output . '<p><a href="'. get_permalink() . '">' . 'Read more >>' . '</a></p>';
}
add_filter('excerpt_more', 'new_excerpt_more');
答案 2 :(得分:1)
这不是回答,只是纠正
您真的不需要在代码中过度使用echo
。只需正确使用打开和关闭php标签。而是使用它。它还有助于提高可读性
<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="inner-box-post">
<h2><a href="get_permalink();"><?php the_title(); ?></a></h2>
<div class="thumbnail">
<?php the_post_thumbnail( 'thumbnail' ); ?>
<?php get_comments( $args ); ?>
</div>
<div class="post-containt">
<div class="post-date"><strong>
<?php get_the_date(); ?>
</strong> </div>
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; ?>
</div>