php - Problem in replacing the_content with the_excerpt()

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 an

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 user2238user2238
Add a comment  | 

1 Answer 1

Reset to default 1

Are 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 &raquo;' . '</a>';
   }
   add_filter('excerpt_more', 'new_excerpt_more');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744910734a4600533.html

相关推荐

  • php - Problem in replacing the_content with the_excerpt()

    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 an

    2天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信