Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #910920

    Hi

    I have manual excerpts on all my posts, one reason being that a lot of them link other sites. I would like to enforce a default excerpt length but for some reason the option for this in the blog customizer doesn’t work for me.

    Any ideas how I can set a default excerpt length for all posts.

    Thanks
    Neil

    #910922
    This reply has been marked as private.
    #911286
    Prasant Rai
    Moderator

    Hello There,

    Thanks for writing in!

    You can add following code in your child theme function.php file:

    if ( ! function_exists( 'x_excerpt_length' ) ) :
      function x_excerpt_length( $length ) {
    
        return x_get_option( 'x_blog_excerpt_length', '60' );
    
      }
      add_filter( 'excerpt_length', 'x_excerpt_length' );
    endif;

    Thanks.

    #913169

    Hi

    Thanks for this but it hasn’t worked. Sorry I am a bit of a newcomer to php editing but where do i add that code in the child theme functions file? At the bottom?

    If you can take a look it would be much appreciated.

    Many thanks
    Neil

    #913601
    Friech
    Moderator

    Hi Neil,

    You can add that code on the bottom of the child theme’s functions.php file. If that does not work, please provide us FTP credentials in private reply, so we can take a closer look.

    Thanks.

    #914094
    This reply has been marked as private.
    #914096
    This reply has been marked as private.
    #914521
    Jade
    Moderator

    Hi Neil,

    Thanks for the details but the FTP access isn’t set to the correct directory.

    Kindly set it correctly so that we could access your site files.

    Thank you.

    #986355
    This reply has been marked as private.
    #986903
    Rue Nel
    Moderator

    Hello Neil,

    Thanks for the updates!

    When you use manual excerpt, it will not apply any word limiter. It will display all the manual excerpt. Word limiter will only be used is it is needed to generate an automatic excerpt from the content.

    The manual WordPress excerpt is often confused with the automatic excerpt or with the teaser (the part of a post that appears on the front page when you use the More tag). While both are related to the manual excerpt, they are different from it.

    The relationship between the three is this: When a post has no manual excerpt and the post template uses the the_excerpt() template tag, WordPress generates an excerpt automatically by selecting the first 55 words of the post. When the post template uses the the_content() template tag, WordPress will look for the More tag and create a teaser from the content that precedes the More tag.

    Learn more about excerpts from here: https://codex.wordpress.org/Excerpt

    #987353

    Ok thanks

    I understand that I am using manual excerpts and that the blog settings don’t affect this.

    Is there any way to add a default excerpt length when using manual excerpts please? This is what I am trying to find out.

    Thanks
    Neil

    #987383
    Rue Nel
    Moderator

    Hello Neil,

    As I mentioned before, the default excerpt length will only be applied if you do not use a manual excerpt. The best way to limit it is to edit your manual excerpt. If you want the excerpt limit, you can remove your manual excerpt and add some contents. By then, the automatic excerpt along with its excerpt length will work.

    Hope this explains briefly.

    #987790

    Ok yes I get the point!

    “I understand that I am using manual excerpts and that the blog settings don’t affect this.”

    But I was trying to find a better way than counting words each time I want to add a manual excerpt. Which is gona be every time as I don’t want to keep using the same content throughout my site.

    Obviously there isn’t a better solution for this aside from counting the words and limiting each manual post excerpt individually. No worries.

    Thanks anyway

    #988166
    Rupok
    Member

    You are welcome and thanks for understanding.

    Have a nice day!

  • <script> jQuery(function($){ $("#no-reply-910920 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>