Forums

Excerpt_more and excerpt_length hooks not working? (8 posts)

  1. AngelEyes
    Member
    Posted 5 months ago #

    These are two functions and filters i took straight from the wordpress codex that are supposed to alter the length of my excerpts and the read more text. Neither of these are doing anything as I'd expect. This is in my functions.php file.

    function custom_excerpt_length( $length ) {
    	return 60;
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
    function custom_excerpt_more( $more ) {
    	return 'Continue reading recipe';
    }
    add_filter( 'excerpt_more', 'custom_excerpt_more' );
  2. AngelEyes
    Member
    Posted 5 months ago #

    when I say that they arent doing anything as I'd expect, I mean they aren't doing anything at all.

  3. esmi
    Theme Diva & Forum Moderator
    Posted 5 months ago #

    Does your theme use the_excerpt()?

  4. AngelEyes
    Member
    Posted 5 months ago #

    Hey Esmi,

    Yes, I'm using the_excerpt on my archive pages and these functions are not effecting it at all.

  5. esmi
    Theme Diva & Forum Moderator
    Posted 5 months ago #

    The first function has always worked first time for me.

  6. AngelEyes
    Member
    Posted 5 months ago #

    hmm i've made some progress on this. I use Starkers as a base theme and it turned out there was a function earlier on setting the read more text.

    there was also one already there for setting the excerpt length but that part of the equation doesn't seem to actually be doing anything. I removed the two functions I'd had before and I successfully have been switching up my read more texts but cant get anything to register on the excerpt_length

  7. AngelEyes
    Member
    Posted 5 months ago #

    This is really killing me...

    I've tried a million variations on

    function custom_excerpt_length( $length ) {
    	return 20;
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

    Thats what I have in my functions.php right now. I have no plugins installed. I can't get this to effect my excerpt length no matter what I seem to do. Any ideas what could be blocking this?

  8. AngelEyes
    Member
    Posted 5 months ago #

    for what its worth, I worked around the problem and did this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

Reply

You must log in to post.

About this Topic