Wordpress read more at end of exert

by ~kev~
10 replies
  • WEB DESIGN
  • |
On my self hosted wordpress blog, I have it setup so that the categories show exerts of the articles - with manually entered exerts when I write the article.

The problem is, at the end of the exert, there is no read more link.

I have tried looking through the wordpress.org site and found this

Function Reference/the excerpt WordPress Codex

Code:
function new_excerpt_more($more) {
	return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');
The instructions said to add that to my theme functions.php file. But when I do, the site either crashes with an error message, or the admin control has errors at the top.

In the archive.php page I added

Code:
<?php the_excerpt('$more'); ?>
but nothing happens to the post - no link is added to read the rest of the article.

I guess I'am doing something wrong with the functions.php file, but I dont know what to do???

This is what my functions.php file says right now.
Code:
<?php
if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'before_widget' => '<div class="block">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widgettitle">',
        'after_title' => '</h3>',
    ));
?>
#end #exert #read #wordpress
  • Profile picture of the author Big Squid
    Where are you inserting it? Be sure to place it after the close of the if statement, but before the close of php.
    {{ DiscussionBoard.errors[2642271].message }}
    • Profile picture of the author ~kev~
      Originally Posted by Avid Reader View Post

      Where are you inserting it? Be sure to place it after the close of the if statement, but before the close of php.
      I inserted it before the if statement, and the error messages went away, but the link to read more is not in the article.
      {{ DiscussionBoard.errors[2642679].message }}
      • Profile picture of the author Harrison Ortega
        Kev, that function doesn't add the link but just replace the [....] with a word given. It is not working because you didn't replace the characters inside the function. It should be like this
        Code:
        function new_excerpt_more() {
            return 'read more...';
        }
        add_filter('excerpt_more', 'new_excerpt_more');
        and you just need to call it using this
        Code:
        <?php the_excerpt(); ?>
        Again, since that function only adds the word "read more" but not a link back to the post. Throw that function out and use this function instead.

        PHP Code:
        function continue_reading_link() {
            return 
        ' <a href="'get_permalink() . '">' __'read more...''' ) . '</a>';
        }

        function 
        auto_excerpt_more(  ) {
            return 
        '&hellip;' continue_reading_link();
        }
        add_filter'excerpt_more''auto_excerpt_more' );

        function 
        custom_excerpt_more(  ) {
            if ( 
        has_excerpt() && ! is_attachment() ) {
                 .= 
        continue_reading_link();
            }
            return ;
        }
        add_filter'get_the_excerpt''custom_excerpt_more' ); 
        Then just call it using
        PHP Code:
        <?php the_excerpt(); ?>
        Harrison
        Signature
        NJ web design / NJ Web Designer. MY Wordpress portfolio. 10 years of HTML/CSS - 6 years developing professional Wordpress websites. Currently not available for services.
        {{ DiscussionBoard.errors[2642878].message }}
        • Profile picture of the author ~kev~
          Originally Posted by Harrison Ortega View Post

          Kev, that function doesn't add the link but just replace the [....] with a word given............
          Thank you, but the following code crashed my site and had to be removed

          Code:
          function continue_reading_link() {
              return ' <a href="'. get_permalink() . '">' . __( 'read more...', '' ) . '</a>';
          }
          function auto_excerpt_more(  ) {
              return '&hellip;' . continue_reading_link();
          }
          add_filter( 'excerpt_more', 'auto_excerpt_more' );
          
          function custom_excerpt_more(  ) {
              if ( has_excerpt() && ! is_attachment() ) {
                   .= continue_reading_link();
              }
              return ;
          }
          add_filter( 'get_the_excerpt', 'custom_excerpt_more' );
          The error message was

          parse error: syntax error, unexpected T_CONCAT_EQUAL
          {{ DiscussionBoard.errors[2643497].message }}
          • Profile picture of the author Harrison Ortega
            Originally Posted by ~kev~ View Post

            parse error: syntax error, unexpected T_CONCAT_EQUAL
            Hi Kev, the BBCode is stripping the code out.
            Just copy it from here [dead link removed]

            I tested on my site and it does work. You can see a test post here [dead link removed]

            Let me know if you can't get it done.

            Harrison
            Signature
            NJ web design / NJ Web Designer. MY Wordpress portfolio. 10 years of HTML/CSS - 6 years developing professional Wordpress websites. Currently not available for services.
            {{ DiscussionBoard.errors[2643700].message }}
            • Profile picture of the author ~kev~
              Originally Posted by Harrison Ortega View Post

              Hi Kev, the BBCode is stripping the code out.
              Just copy it from here.................
              That is perfect - thank you very much!!!!!!!

              Not having a "read more" link in the exert seems like an oversight on part of the wordpress developers. My opinion, there should be a link there be default, and an easy way to edit the link text.
              {{ DiscussionBoard.errors[2643801].message }}
              • Profile picture of the author Harrison Ortega
                Originally Posted by ~kev~ View Post

                That is perfect - thank you very much!!!!!!!

                Not having a "read more" link in the exert seems like an oversight on part of the wordpress developers. My opinion, there should be a link there be default, and an easy way to edit the link text.
                I'm glad you got it working.
                BTW, to change the read text, just find the 'read more...' in the function and change it to something else.

                Harrison
                Signature
                NJ web design / NJ Web Designer. MY Wordpress portfolio. 10 years of HTML/CSS - 6 years developing professional Wordpress websites. Currently not available for services.
                {{ DiscussionBoard.errors[2643809].message }}
  • Profile picture of the author jakeseth12
    Thanks for sharing such wonderful source of information. I am glad that I came here (on this forum) and got to learn something new.
    {{ DiscussionBoard.errors[2673670].message }}
  • Profile picture of the author y2gabs
    Try using the advanced excerpt plugin instead
    {{ DiscussionBoard.errors[2727255].message }}
    • Profile picture of the author zapa2005
      Hi there,


      "Try using the advanced excerpt plugin instead "
      I'm self hosted and tried to install advanced excerpt but can't seem to find how to configure it though? Any tip?

      Thanks, H
      {{ DiscussionBoard.errors[3912827].message }}

Trending Topics