• Resolved Spencer Hill

    (@s3w47m88)


    According to the Codex, as I understand it, I should just be able to post the code sample it provides and that will automatically change the length of the output from the_excerpt(). But that doesn’t work. Can anyone help me understand what I’m doing wrong?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • @s3w47m88, you’ll need to be more specific for anyone to help you.

    What code did you copy? Where did you put it? What theme are you trying to modify?

    Thread Starter Spencer Hill

    (@s3w47m88)

    Thanks for the reply.

    Sorry I thought my message was clear. The code I placed is on the Codex section that I linked directly too, and it says that belongs in the functions.php file. My theme is custom.

    Thanks!

    It does seem like that should work. Some things you can rule out (sorry if these are obvious, but it seems worth double-checking)”

    • Make sure that your template displaying the excerpt text is showing the_excerpt() and not the the_content().
    • Make sure you haven’t filled in the “Excerpt” field on the posts you’re using to test. (The excerpt_length filter only modifies the length of auto-generated excerpts from the beginning of the body, not the length of the “Excerpt” field).
    • Does it work with all your plugins disabled?
    • Have you turned on WP_Debug to make sure there aren’t any errors?
    Thread Starter Spencer Hill

    (@s3w47m88)

    Ah, thanks mrwweb. I didn’t fully understand how the_excerpt worked apparently.

    Just for any others that might read this, here’s what I discovered that fixed the issue.

    the_excerpt() function will display content from the_content() if there isn’t any text in the excerpt metabox (that’s the panel called “Excerpt” when you’re editing a page). And the truncate function, from above, doesn’t truncate content from the “Excerpt” metabox! It only truncates the text if it pulls from the_content().

    I presume this is because WordPress assumes if you’re writing an excerpt you can manually ensure it’s the proper length.

    But in my case the excerpt is displaying in two spots so I would have liked it to truncate in one spot but not the other. Which I didn’t find a solution for.

    Hope that makes sense! I know it’s a mouthfull!

    I wondered whether that was it. It took me ages to originally figure that out.
    Glad I could help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘I don't understand the excerpt length, need help…’ is closed to new replies.