Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #17278

    Hi,

    I would like to use my own, special, individual excerpts of posts, that should be shown on the blog overview page. These texts differ from the post’s content and therefor I don’t want to use the more-tag.

    For this I use the text box below, when writing a post, but CORONA ignores such individual excerpts and shows the complete post content.

    1.

    How can I use individual excerpts of posts within the theme?

    2.

    How can I limit the number of words or characters, when using these individual excerpts, in case if I write too much in the excerpt text box?

    Thanks.

    #94813

    I found in another theme’s forum this and changed in loop-index.php

    this

    <div class="entry-content"><br />
    <?php<br />
    if(strpos($avia_config['layout'], 'medium_image sidebar') !== false) echo $slider->display_small('blog');<br />
    the_content(__('Read more →','avia_framework'));<br />

    to this

    <div class="entry-content"><br />
    <?php<br />
    if(strpos($avia_config['layout'], 'medium_image sidebar') !== false) echo $slider->display_small('blog');<br />
    the_excerpt(__('Read more →','avia_framework'));<br />

    This shows me my individual excerpt on a blog overview page. But:

    a)

    when I click the post title, then the complete post content is this individual excerpt only, and the actual post content is away,

    b) my individual excerpt do not show “read more”. How can I add this again, too, as it is the case when using the normal “more” tag – and how to limit its characters to, for example 50?

    I have put around 100 words in the individual excerpts text box for testing it and in my functions.php I put this code, that I’ve found anywhere, but I don’t know, if it is right:

    <br />
    /** Modify the length of post excerpts */<br />
    add_filter( 'excerpt_length', 'custom_excerpt_length' );<br />
    function custom_excerpt_length($length) {<br />
    return 50; // pull first 50 words<br />
    }<br />

    Thanks.

    #94814

    Use following code instead:

    <div class="entry-content">
    <?php
    if(strpos($avia_config['layout'], 'medium_image sidebar') !== false) echo $slider->display_small('blog');
    if(!is_single()){
    the_excerpt(__('Read more →','avia_framework'));
    echo '<a class="more-link" href="'. get_permalink().'">'.__('Read more &rarr;','avia_framework').'</a>';

    }else{
    the_content(__('Read more →','avia_framework'));
    }

    #94815

    Thanks a lot, Peter, it works fine now for my excerpt.

    But as mentioned above:

    how can I limit my indidivual excerpt to, let’s say 50 words?

    I’ve found in this tutorial this part of code, put it in CORONA’s function.php, but it doesn’t work, the excerpt is not limited; as said above, I use now my own individual excerpt, not using the “more”-tag:

    /** Modify the length of post excerpts */
    add_filter( 'excerpt_length', 'custom_excerpt_length' );
    function custom_excerpt_length($length) {
    return 50; // pull first 50 words
    }

    When I delete my own custom excerpt, then this code seems to work, it shows me the first around 50 words of this post.

    But as soon as I put in my own custom excerpt in the text box for it, then nothing is limited at all, no limitation of the – individual – excerpt.

    #94816

    Hi!

    Yes, wordpress will use the custom/individual excerpt text in this case and it won’t apply the excerpt_length filter to it.

    Regards,

    Peter

    #94817

    Again my question:

    As soon as I put in my own custom excerpt in the text box for it, then nothing is limited at all, no limitation of the – individual – excerpt. How can I limit the custom excerpt?

    Thanks.

    #94818

    I believe your source function is incorrect, try:

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

    This one is from the wordpress codex on the_excerpt: http://codex.wordpress.org/Function_Reference/the_excerpt#Control_Excerpt_Length_using_Filters

    Regards,

    Devin

    #94819

    thanks, but I need to start from the scratch; somehow nothing is working right anymore. I deleted all these code of mine, replaced my functions.php and the loop-index.php with the original ones; and in future I won’t use a custom excerpt anymore.

    With some try&error I have now in my functions.php:

    /** Modify the length of post excerpts */

    add_filter( 'excerpt_length', 'custom_excerpt_length' );

    function custom_excerpt_length($length) {

    return 20; // pull first 50 words

    }

    and in the loop-index.php this part of code:

    <?php

    if(strpos($avia_config, 'medium_image sidebar') !== false) echo $slider->display_small('blog');

    if(!is_single()){

    the_excerpt(__('Read more ?','avia_framework'));

    echo ''.__('Read more →','avia_framework').'';

    }else{

    the_excerpt(__('Read more ?','avia_framework'));

    }

    It works fine so far, but I would like to get rid of this [...]:

    How can I do this?

    Thanks.

    #94820

    Hi!

    Try to add following code to the bottom of functions.php:

    function new_excerpt_more( $more ) {
    return;
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    Best regards,

    Peter

    #94821

    Works now perfect, thank you all together for your help!

    #94822

    Glad its working for you now :)

    Regards,

    Devin

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘How to use individual post excerpts with CORONA?’ is closed to new replies.