WordPress.org

Forums

[resolved] Remove ... from excerpt (27 posts)

  1. zeaks
    Member
    Posted 4 years ago #

    Using a Twenty ten child theme, how can I completely remove the ... after the excerpt? I know how to change the continue reading text, which I have done. I've also tried code snippets posted on these forums, but they leave behind a [...] instead.

    This is one post I found, the code posted dind't work for me.
    http://wordpress.org/support/topic/remove-continue-reading-from-twentyten?replies=16

  2. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    Always check the Codex first. See this, from the entry for the_excerpt().

    You need to use the excerpt_more filter. For example, to completely remove the "[...]":

    function new_excerpt_more($more) {
    	return '';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
  3. keesiemeijer
    moderator
    Posted 4 years ago #

    [edit] Oops, too late.

  4. zeaks
    Member
    Posted 4 years ago #

    Thanks, but it didn't seem to do anything

  5. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    Where did you put that code?

  6. zeaks
    Member
    Posted 4 years ago #

    in my functions.php

  7. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    Just to test, try this:

    function new_excerpt_more($more) {
    	return 'Can you hear me now?';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
  8. zeaks
    Member
    Posted 4 years ago #

    No change with that. I'm not sure if this matters, but I did change the continue reading link

    Here is my functions file
    http://wordpress.pastebin.com/q55EDZnd

  9. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    I don't see the excerpt_more filter anywhere in your functions.php file?

  10. zeaks
    Member
    Posted 4 years ago #

    It's in my current one, here it is with the code in it http://wordpress.pastebin.com/XyfJaDBG

  11. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    First thing to try: comment-out the gettext filter, to determine if it is potentially interfering with the excerpt_more filter?

  12. zeaks
    Member
    Posted 4 years ago #

    I commented out add_filter('gettext', array('Twentyten_Child_Text_Wrangler', 'reading_more'), 10, 4); it's still showing the ... though

  13. zeaks
    Member
    Posted 4 years ago #

    I tried that code above into a new child theme with just that in the functions and it doesn't remove the ... part

  14. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    Maybe try wrapping the add_filter call in an add_action( after_setup_theme... hook, as you have with your change_excerpt_length() function?

    function change_excerpt_more(){
       function new_excerpt_more($more) {
            return 'Can you hear me now?';
       }
       add_filter('excerpt_more', 'new_excerpt_more');
    }
    add_action( 'after_setup_theme', 'change_excerpt_more' );
  15. zeaks
    Member
    Posted 4 years ago #

    hmm, well that removes it, but it's also removed the text part of it. Thanks for all the help btw

  16. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    What "text part"? It should only be removing the default "[...]".

  17. zeaks
    Member
    Posted 4 years ago #

    It removes the "continue reading" text....editing this, it adds "can you hear me now" I didn't notice it at first look

  18. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    Did you un-comment the bit we commented out earlier?

  19. zeaks
    Member
    Posted 4 years ago #

    Yes it's un-commented now, and still showing the "can you hear me now" part

  20. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    Well, you can change:

    'Can you hear me now?'

    To:

    ''

    Then, we just need to figure out why excerpt_more is interfering with read_more.

  21. zeaks
    Member
    Posted 4 years ago #

    It seems to work the same with the new child theme I made with nothing in the functions.php besides the code you posted above. If I remove the "can you hear me now" part , it doesn't show any "continue reading" text either
    You can see it here http://test.zeaks.org/

    Nothing else is in the functions file

  22. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    What do you want the "Read More" link to say, exactly? Will this work?

    function change_excerpt_more(){
       function new_excerpt_more($more) {
            return '[Read More]';
       }
       add_filter('excerpt_more', 'new_excerpt_more');
    }
    add_action( 'after_setup_theme', 'change_excerpt_more' );
  23. zeaks
    Member
    Posted 4 years ago #

    Well I want it to be linked. I just wanted to remove the ... part of the line so instead of saying

    post summary ... Continue Reading ->
    it would say
    post summary Continue Reading ->

    But have the continue reading text hyperlinked, it's just plain text now.

  24. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    You want it to be linked on the Excerpt, or just with the More Tag?

    I think the disconnect here might be that you don't actually want to modify the excerpt, but rather the Read More link.

    If so, forget everything we've done so far, and try this. Inside your Loop, replace your call to:

    <?php the_content(); ?>

    with this:

    <?php the_content( '<span class="read-more">Read More <span class="meta-nav">&raquo;</span></span>' ); ?>
  25. zeaks
    Member
    Posted 4 years ago #

    I just wanted to get rid of the ... but what you posted earlier ended up working, I just had to link the "read the rest" text to the post. Here is what I have in my functions, I removed the original code I had to change the continue reading text and added

    /* remove the ... from excerpt and change the text*/
    function change_excerpt_more(){
       function new_excerpt_more($more) {
            return '<span class="read-more"><a href="'. get_permalink($post->ID) . '">Read the Rest ยป</a></span>';
       }
       add_filter('excerpt_more', 'new_excerpt_more');
    }
    add_action( 'after_setup_theme', 'change_excerpt_more' );

    The read-more span class isn't needed, but I wanted it to be placed on another line after the excerpt for one of my layouts and used display: block; to do so. http://test.zeaks.org

    Thanks alot for all the help, I've been trying to figure this out for a while.

  26. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    Awesome! Glad you got it working.

  27. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    (p.s. be sure to mark the topic "resolved", to help others who might be looking to solve a similar issue.)

Topic Closed

This topic has been closed to new replies.

About this Topic