我无法找到一种方法来包含每个帖子的链接。当我插入
<a href="<?php the_permalink() ?>">Read more</a>
洞边栏消失了。我如何使用the_permalink()?
“sidebar-right.php”:
<div id="sidebar-right">
<div id="news">
<h1 class="news">Nyheter</h1>
<div class="border"></div>
<?php
$args = array( 'numberposts' => 3 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post);
?>
<h2 class="news"><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
//here I want the link
<?php endforeach; ?>
<div class="border"></div>
</div>
</div>
在functions.php中:
function new_excerpt_more($more) {
return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
答案 0 :(得分:1)