Tagged: excerpt, layout, limit, related posts
-
AuthorPosts
-
May 26, 2017 at 10:49 pm #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-691749add_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.May 28, 2017 at 12:06 pm #800773Hey 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,
VictoriaMay 29, 2017 at 2:06 pm #801092June 1, 2017 at 7:23 am #802383Hi,
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,
IsmaelJune 1, 2017 at 1:18 pm #802526Thank 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!
June 2, 2017 at 7:03 am #802886Hi,
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,
IsmaelJune 2, 2017 at 11:56 am #802954Thank you very much, works fine, Ismael!
Can I limit the related posts below a post
to always only 4 related posts?June 2, 2017 at 12:03 pm #802957Great, 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!
June 6, 2017 at 7:51 am #804366 -
AuthorPosts
- The topic ‘Add MANUAL (!) excerpt to the "related posts" – suggested snippet not working’ is closed to new replies.