WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] I can't change excerpt length, even with plugins (9 posts)

  1. Colby Ross
    Member
    Posted 2 years ago #

    Hello, I'm fairly new to wordpress, but I have a site up and running at:
    http://www.ios-source.com

    The problem is that instead of showing a certain amount of characters or words in the post excerpt, it just shows the entire post.

    I've tried adding this code to my theme's functions.php file, but it does nothing:

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

    I've also tried out a few plugins like Excerpt Length and Advanced Excerpt, but nothing works.

    I've tried using the Twenty Eleven theme and the Twenty Ten theme, but neither of those work with the two plugins I wrote about above.

    Could someone please help me with this? I need to change the amount of words in the post excerpt. Thank you.

  2. davidsword
    Member
    Posted 2 years ago #

    Are you filling in the Except's metabox? Are you using the more button?

    There are many different ways themes split content for excerpt (and note in cases some users forget to split there content, and in other cases theme authors forget to write all splitting methods)

  3. Colby Ross
    Member
    Posted 2 years ago #

    I tried filling in the Excerpt box, but it did nothing. No matter what theme I used, even on the Twenty Eleven theme, it would not work.

    I did try the more button, which I didn't even know existed (thank you), and that did work.

    But I would prefer if I could use excerpts, and so far it would not work, I don't believe it has anything to do with the theme I am using, because I can't get it to work on any theme.

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    Twenty Ten and Twenty Eleven do not use the excerpt code on the index page; so they are bad examples to test your plugins.

    for the excerpt to show, you need to edit the template which shows the front/posts page (often index.php; but loop.php in Twenty Ten, and content.php in Twenty Eleven) and change the code to use the_excerpt() instead of the_content()

    as you are using a custom theme, have a look at http://codex.wordpress.org/Template_Hierarchy to identify what template to edit.

    http://codex.wordpress.org/Function_Reference/the_excerpt

  5. Colby Ross
    Member
    Posted 2 years ago #

    I couldn't try the above method because I found that "the_content()" doesn't even exist in my template. I found this out by searching for "the_content()" in all the files in my template folder using Notepad++.

    I did see that "the_content()" exists in Twenty Ten and Twenty Eleven, so I went into Twenty Ten and changed "the content()" to "the excerpt()", and it still did nothing.

  6. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    your theme might have the_content('read more') or so - try to search for just the_content

    or try to get in contact with whoever made your theme...

  7. Colby Ross
    Member
    Posted 2 years ago #

    Okay, I did that.

    In /helpers/system.php, it says:
    remove_filter('the_content', 'wpautop');

    In /layouts/page.php, it says:
    <div class="content clearfix"><?php the_content(''); ?></div>

    In /layouts/single.php, it says:
    <div class="content clearfix"><?php the_content(''); ?></div>

    In /layouts/_post.php, it says:
    <div class="content clearfix"><?php the_content(''); ?></div>

    Could you please tell me which one I have to edit, and what I edit it to?

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    my guess would be:

    in /layouts/_post.php,

    and change it to:

    <div class="content clearfix"><?php the_excerpt(); ?></div>
  9. Colby Ross
    Member
    Posted 2 years ago #

    That did the trick. Thank you very much!

Topic Closed

This topic has been closed to new replies.

About this Topic