I want to add read more to a blog. For that I need to replace the function the_content()
. I found it in the loop file and replaced it with the_excerpt()
but still posts are being shown of full length. Please help out.
EDIT: Here is the site. The read more is added now(I replaced all the occurences of the_content with the_excerpt). It gave rise to a new problem. All the links on the page are not working correctly. Please have a look.
I want to add read more to a blog. For that I need to replace the function the_content()
. I found it in the loop file and replaced it with the_excerpt()
but still posts are being shown of full length. Please help out.
EDIT: Here is the site. The read more is added now(I replaced all the occurences of the_content with the_excerpt). It gave rise to a new problem. All the links on the page are not working correctly. Please have a look.
Share Improve this question edited Aug 7, 2011 at 2:33 asked Aug 7, 2011 at 1:40 user2238user22381 Answer
Reset to default 1Are you sure you have replaced it in the correct template file?
I found a useful way to tell by adding this to the functions.php file:
<?php
add_action( 'wp_head', 'adminbar_print_template' );
function adminbar_print_template() {
global $template, $current_user, $wp_admin_bar;
get_currentuserinfo();
/* If you have more than one user deny. Be sure to use your user ID! */
if ( !is_user_logged_in() && $current_user->ID != '1' )
return;
if ( is_admin_bar_showing() )
$wp_admin_bar->add_menu( array(
'parent' => false,
'id' => 'template',
'title' => $template,
'href' => '#'
));
else
print_r( $template );
}
?>
If you have the Show Admin Bar settings set to "show when viewing site", it will output the current template file being used on the page you are viewing. Another possibility could be that your theme uses a loop.php file, and you will need to modify it for the excerpt.
TIP: Add this to your functions.php file so the "Read More" tags are actually links to the posts:
function new_excerpt_more($more) {
global $post;
return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More »' . '</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744910734a4600533.html
评论列表(0条)