Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 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');
share|improve this answer
    
I tried the way wordpress.org suggested. Now I am stuck with a weird problem, the posts do have read more option but ALL the links on the blog are not working correctly. can you help out? Have a look pricelessproject.com/wordpress –  Fahad Uddin Aug 7 '11 at 2:29
    
I viewed your site and they seemed to work correctly. What page/links specifically are you having problems with? –  Jeremy Jared Aug 7 '11 at 2:33
    
Its pricelessproject.com/wordpress . I tried again but NONE of the links are working correctly. I am being redirected to the homepage.For example, click read more on any of the post and you will be redirected to the homepage. Same problem with all the links –  Fahad Uddin Aug 7 '11 at 2:35
    
I see now. Have you checked to make sure you removed all the old read more code? You need to remove what you had and replace it with what I've posted. In your template files, you need to put <?php the_excerpt(); ?> –  Jeremy Jared Aug 7 '11 at 4:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.