• Resolved markusjj

    (@markusjj)


    I need to somehow increase the current excerpts’ limit of 200 chars on the front page. 200 chars just isn’t enough to highlight the main marketing message and to catch attention… Also, from SEO standpoint, it’s not enough content. So I tried to follow this snippet, but after modifying the child functions.php I fail to see any change to the max excerpt length.

    I have enough programming knowledge to play with css and php. But I would appreciate some pointers from the resident experts here. Where should I start modifying my child theme? Any snippets of code would also be very much appreciated.

    BTW, I’m new to this forum. But I sincerely appreciate the vibrant Customizr community. Nicolas has done an incredible job to create this wonderful and clean theme and to establish such lively and enthusiastic team of volunteers around it. Awesomeness!

    Cheers,
    Markus

Viewing 10 replies - 1 through 10 (of 10 total)
  • The limit is not 200, but 55. If you want to raise it to any number, use the snippet you linked, but change 200 to whatever you want.

    The limit you set only applies to the auto-generated excerpts. You can always set your own unlimited excerpt, with full html. Just go to screen options (up right corner) in any post’s edit page and check Excerpts. The Excerpt metabox will appear somewhere under the content metabox and you’re free to input anything there. If you want to enable excerpts for pages (or any custom post type), use this code for each post type you want to excerpts for, in your child theme’s functions.php (change “page” to whatever you need):

    add_post_type_support( 'page', 'excerpt' );

    More details here.

    Thread Starter markusjj

    (@markusjj)

    Acub, thank you kindly for your reply and the tips. I will check them out tomorrow morning.

    Apparently one of us is a bit confused and befuddled… I bet it’s me. Cheers.

    Thread Starter markusjj

    (@markusjj)

    My confusion is all about the limit of characters. No matter what I try to do, the theme is always limiting me to 200 chars. I cannot exceed it. Here’s what I did.

    1. In child functions.php, I added the snippet from @niko to enable the Screen Options with custom excerpts for Pages. So that is working fine.
    2. In child functions.php, I added the snippet from Dave (same link as above) and set the max value to 450 chars.
    3. In WP admin, for the page, I added a manual custom snippet about 400 chars long.
    4. In WP admin in Customizr, I went to Front Page, selected the page with my new custom excerpt, but left the field box for that page empty.

    The result is that only the custom text is not used. Only the default 200 chars from that page content are displayed. I can also copy and paste a longer excerpt into the field in Customizr, but then the output will always be truncated to 200 chars. Here is the entire content of my child functions.php (first function is irrelevant here, footer-related snippet.)

    <?php
    /* Customizing the footer credits and adding links */
    add_filter('tc_credits_display', 'my_custom_credits');
    function my_custom_credits(){
    $credits = 'Theme: <a href="http://www.themesandco.com/">Themes & Co</a>';
    $newline_credits = '<a class="footer-nav" href="http://brainsonwings.com/terms-of-service/">Terms of service</a> &middot; <a class="footer-nav" href="http://brainsonwings.com/privacy-policy/">Privacy policy</a>';
    return '
    <div class="span4 credits">
                        <p> &middot; &copy; '.esc_attr( date( 'Y' ) ).' <a href="'.esc_url( home_url() ).'" title="'.esc_attr(get_bloginfo()).'" rel="bookmark">'.esc_attr(get_bloginfo()).'</a> &middot; '.($credits ? $credits : 'Designed by <a href="http://www.themesandco.com/">Themes & Co</a>').' &middot;'.($newline_credits ? '<br />&middot; '.$newline_credits.' &middot;' : '').'</p>        </div>';
    }
    
    /* Change the length of the excerpts on home page */
    function your_excerpt_length( $length ) {
    return 450;
    }
     add_filter( 'excerpt_length', 'your_excerpt_length' );
    
    /* Add custom excerpts for home page */
    add_action( 'init', 'my_add_excerpts_to_pages' );
    function my_add_excerpts_to_pages() {
         add_post_type_support( 'page', 'excerpt' );
    }
    ?>

    This thing is driving me nuts. It should be simple, I know. But my PHP expertise is rather limited, so if somebody can see a bug or a flaw in my thinking, I really would appreciate help. Thanks.

    Thread Starter markusjj

    (@markusjj)

    Just to sum it up. What I’ve been trying to say here is that the theme seems to be overriding the Excerpt metabox content and/or truncating it. Acub, what you wrote yesterday, does not seem to hold true for me.

    The limit you set only applies to the auto-generated excerpts. You can always set your own unlimited excerpt, with full html. Just go to screen options (up right corner) in any post’s edit page and check Excerpts.

    Have you been able to check it yourself? At least I have failed to make it work… (Of course, it could be the usability issues of all the combined knobs, switches, buttons, pull-downs, text boxes, etc… WP is awesome, but somewhat convoluted.)

    You can see a test here. I have set the excerpt manually and no matter what limit I set for excerpts they are always shown exactly as I set them in the post’s edit screen.

    I can only guess you have a filter/limitation set by some plugin or some snippet you applied that limits the length of your manual excerpts. Try to disable any snippets/plugins related to excertps and see if that fixes it. Also, you might want to change the setting from Dashboard > Settings > Reading. That setting normally only applies to feeds.

    Other than that, I’m all out of ideas. Normally, if you install the theme clean and set the excerpt manually to a post/page/custom-post-type it will display exactly as you set it, regardless of WP’s limit on excerpts.

    Thread Starter markusjj

    (@markusjj)

    Aahh, now I see we were discussing and trying to solve 2 completely different things. Sorry if I did not communicate my point clearly… (I wish this forum had an easy screenshot attachment capability.)

    What I am trying to achieve is completely different. I am trying to expand the “excerpts” that sit right below the featured images, gray circles, and below your example page h2 About headings (so in your example, these are defaults). The UI path is Customize > Front Page > Featured Pages Options > 3 sections: [Featured text one, Featured text two, Featured text three]. And I wouldn’t care if I needed to create these featured text sections manually or extract them from the beginning of each page. Any approach is good. But it really would be lovely if these 3 text “excerpts” could be longer than 200 chars.

    By the way I do not care about the Featured Posts on page. So on my site the section your example of “Hello world! with “Lorem Ipsum” is disabled and not displayed.

    Acub, I really do appreciate your helping me out! and my apologies for not describing my issue clearly…
    Thanks again.

    I finally understood what you’re after.

    Copy class-content-featured_pages.php from customizr to /wp-content/themes/{child-theme-folder}/parts and comment-out (or just delete) lines from 135 to 142.

    This solution allows you to disable the limitation, but you will lose any future updates of this file, as the one in your child theme takes precedence over the file in parent theme. You can avoid this by re-applying the same mod after each customizr update and saving the modded file from customizr over the version in your child theme.

    Thread Starter markusjj

    (@markusjj)

    Hmm… Great. I see. Thanks for pointing me in the right direction, it is good to know the mechanism that sets this limit. So I see it is doable, but not a clean or elegant solution.

    Am I to understand that right now there is no easy hook nor API modification that can be implemented by end-users only by altering the child functions.php?

    I do believe this would be a very nice extra hook for further customization of the theme. The 200 value limit should not be hard-coded. What does Nikeo think?

    Theme Author presscustomizr

    (@nikeo)

    hi @markusjj : in the coming release, there is a bunch of new filter to allow (almost) total control of featured pages
    Thanks for pointing this out

    Thread Starter markusjj

    (@markusjj)

    That’s awesome! Looking forward to the next release(s). Cheers.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Increase limit of 200 chars featured text excerpt’ is closed to new replies.