2013-03-03 172 views
0

我有下面的代码,但它出现在更多的链接无法正常工作,请会有人头脑帮助,我已经激活功能文件摘录:摘录发表在WordPress的帖子

查询后下: -

<?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;?> 

回答

0

你可以使用这个编辑器按钮:

enter image description here

拆分内容:

enter image description here

enter image description here

然后它会显示你这样的概述页面:

enter image description here

在默认主题二十二您使用此代码:

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

显示Continue reading链接。

所以你的情况,你可以使用:

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

嗨,那里,我做了这个,它不工作,因此我认为这是我的PHP代码 – 2013-03-03 13:36:06

+0

我更新了与PHP代码的答案。 – birgire 2013-03-03 13:43:18

+0

你能解释一下'read the link is not working'是什么意思吗?你的意思是你的代码中'the_excerpt'函数之后的链接。 Ps:你应该使用'posts_per_page'而不是旧的'showposts'参数。 – birgire 2013-03-03 14:08:18

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>'; 
} 

然后在需要的地方使用:

希望这有助于,th e WP codex也有一些令人敬畏的摘录文件http://codex.wordpress.org/Excerpt

相关问题