在Wordpress Post中摘录帖子

时间:2013-03-03 13:02:35

标签: wordpress blogs

我有以下代码,但是看起来读取更多链接不起作用,请有人介意协助,我已经激活了函数文件中的摘录:

以下查询帖子: -

<?php $the_query = new WP_Query( 'showposts=5' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php the_excerpt('Read more...'); ?>
<a href="<?php echo get_permalink(); ?>"> Read More...</a>
<?php endwhile;?>

2 个答案:

答案 0 :(得分:0)

您可以使用此编辑器按钮:

enter image description here

分割内容:

enter image description here

enter image description here

然后它会在您的概述页面上显示如下:

enter image description here

在默认主题Twenty Twelve中,您可以使用以下代码:

<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>

显示Continue reading链接。

所以在你的情况下你可以使用:

<?php the_content("Read more ...");?>

答案 1 :(得分:0)

一直为我的项目提供良好服务的简单解决方案是在functions.php中声明一个简单的函数,如下所示:

add_filter('excerpt_more', 'new_excerpt_more');
function new_excerpt_more($more) {
    global $post;
    return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More ...' . '</a>';
}

然后使用以下方式拨打需要的摘录:

<?php the_excerpt(); ?> 

希望这有帮助,WP codex在摘录http://codex.wordpress.org/Excerpt

上也有一些很棒的文档