Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #800428

    Hi,

    I’m using manual excerpts with each post.
    How can I add these manual excerpts to the related posts?

    ———- (1) ———-

    I found this snippet from @Yigit, but I don’t know, if this works right with MANUAL (individual) excerpts:
    https://kriesi.at/support/topic/add-excerpt-text-in-the-related-post-field/#post-691749

    add_filter('avf_related_post_loop','avia_related_excerpt');
    function avia_related_excerpt() { 
      $excerpt = get_the_excerpt( $post );
      $output = "<span class='related-excerpt'>".$excerpt."</span>";
      return $output;
    } 

    but this snippet makes a mess in my related posts:

    EDIT: it seems that this snippet adds the manual excerpt to the “related posts” of the post you are currently viewing!

    ———- (2) ———-

    The suggested CSS

    strong.av-related-title {
        float: left;
    }
    span.related-excerpt {
        float: right;
    }

    are acting weird: the thumbnail of the related posts is not at the right place:

    Any ideas please?
    Thank you.

    #800773

    Hey Chris,

    Try this code:

    
    add_filter('avf_related_post_loop','avia_related_excerpt');
    function avia_related_excerpt($related_post) { 
      $excerpt = get_the_excerpt( $related_post );
      $output = "<span class='related-excerpt'>".$excerpt."</span>";
      return $output;
    } 
    

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #801092

    Thanks, but that snippet has no other effect than the first one I mentioned above:

    The manual/individual excerpts texts are the same, although there are 3 different (!) posts, as you can see in the screenshot.
    See the posts and backend in the private data above please. Thanks.

    #802383

    Hi,

    Thank you for the update.

    Please remove the previous css modifications then follow these steps.

    1.) Add this code in the functions.php file:

    add_filter('avf_related_post_loop','avf_related_post_loop_excerpt_mod', 10, 2);
    function avf_related_post_loop_excerpt_mod($output, $related_post) {
      $output = "<span class='related-excerpt'>".$related_post->post_excerpt."</span>";
      return $output;
    }
    

    2.) And this code in the Quick CSS field.

    .related-excerpt {
        display: table-cell;
        vertical-align: middle;
        padding: 5px 15px;
        line-height: 1.2em;
    }
    

    3.) Smile. :)

    Best regards,
    Ismael

    #802526

    Thank you very much, Ismael, it works fine in that way, that now the right excerpt is together with the right post(title).
    Just one thing please:

    how can I place the excerpt below and aligned with the title like this Photoshop composing:
    title over the whole width and excerpt text below it and aligned left with the title:

    I tried it with your CSS and “float: left;” but for some reason this does not work. Do you have any idea how to modify the CSS? Thanks a lot!

    #802886

    Hi,

    Thank you for the update.

    Please replace the css code with the following.

    #top .av-related-style-full .av-related-title, #top .av-related-style-full .related-excerpt {
        display: block;
        position: relative;
        top: -20px;   
    }
    
    #top .av-related-style-full .related-excerpt {
        color: #444444;
        font-size: 13px;
        line-height: 140%;
        padding: 5px 15px;
    }
    

    Best regards,
    Ismael

    #802954

    Thank you very much, works fine, Ismael!

    Can I limit the related posts below a post
    to always only 4 related posts?

    #802957

    Great, I got it with the limitation from your snippet here:

    and changed there
    'columns' => 6,
    to
    'columns' => 4,

    Great, I’m happy with the result, appreciate your help, Ismael!

    #804366

    Hi,

    No problem. Let us know if you need anything else. :)

    Best regards,
    Ismael

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Add MANUAL (!) excerpt to the "related posts" – suggested snippet not working’ is closed to new replies.