![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
-
AuthorPosts
-
June 21, 2021 at 11:43 am #1306704
Hi,
it is possible to sort the “You might also like” Posts on the bottom of a Single Post by date starting from the current post?
The result would be a kind of “previous” and “next” with the layout of the related posts.I have already edited the related-posts.php file in this way (line 77):
$my_query = get_posts(
array(
‘tag__in’ => $tag_ids,
‘post_type’ => get_post_type($this_id),
‘showposts’=>$postcount, ‘ignore_sticky_posts’=>1,
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘post__not_in’ => array($this_id))
);
Or do you have other tips to get the same result?
Thank you very muchJune 22, 2021 at 6:46 am #1306867Hey Stefano,
Thank you for the inquiry.
Editing the template file directly should be enough to adjust the query. We can use hooks such as pre_get_posts but that would mean filtering other queries to make sure that we are actually adjusting the query for the related posts, which is more complicated than adjusting the query directly from the template.
Best regards,
IsmaelJune 22, 2021 at 10:00 am #1306895Hi,
thanks for the reply.
I’m not very familiar with php so I did not understand how to fix it :)
Can you help me by showing me what I can do?
If needed, I can attach the related-posts.php template to the tread.
ThanksJune 23, 2021 at 8:20 am #1307089Hi,
Thank you for the update.
Yes, please post the content of template file using pastebin.com, or provide the login details in the private field so that we can test it properly. Make sure that the Appearance > Editor panel is accessible.
Best regards,
IsmaelJune 23, 2021 at 9:05 am #1307094Thanks
June 25, 2021 at 6:26 am #1307394Hi,
Looks like it is already displaying the posts by date. The two adjacent posts to casa-del-horno sorted by date and with the same tag “Panama” are casa-nuratti and casa-perez. Please note that the related posts section will display posts with the same tag as the current post.
Which posts would you like to see in the related posts section when the current post is casa-del-horno?
Best regards,
IsmaelJune 25, 2021 at 8:39 am #1307412Hi,
for example in “Casa de Oro” (http://redgroup.masmo.it/casa-de-oro/) of the “Panama city” category I should see “casa perez” as prev and “Casa Abrahams y Dolores” as next.
Instead I see “Casa del Horno” and “Casa Nuratti”.June 28, 2021 at 7:55 am #1307671Hi,
Thank you for the info.
This is possible, but you have to use the get_adjacent_post function to get the next and previous posts, queried by date. Or enable the Enfold > Blog Layout > Single Post Navigation option, which is already using the get_adjacent_post function out of the box.
// https://developer.wordpress.org/reference/functions/get_adjacent_post/
// https://core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/link-template.php#L1088The related posts section are already queried by date but it fetches all related posts from the top irregardless of the current post.
Best regards,
IsmaelJuly 1, 2021 at 11:01 am #1308292Thank you but I’m not good with php.
Could you help me by implementing the code to work on my site?
My only need is that the layout remains the same but the “next” and “prev” navigation works following the order of the posts starting from the post I am viewing.
I can give you all the accesses.
If there is an additional fee to pay let me know how much.
Thank youJuly 2, 2021 at 5:16 am #1308459Hi,
Unfortunately, this customization is beyond the scope of support, so we will not be able to help you. Have you tried enabling the post navigation instead? You can find the Single Post Navigation option in the Enfold > Single Post Options. The navigation is using the get_adjacent_post function out of the box.
Best regards,
IsmaelJuly 2, 2021 at 9:20 am #1308471Hi,
thanks for the reply.I tried to activate post navigation but it has a different layout.
I need it to be at the bottom of the page and with the same content that is now in the section.
See for example this link: http://redgroup.masmo.it/casa-nuratti/Can you support me in the development?
In this case I await a quote from you.Thanks so much
July 5, 2021 at 11:27 am #1308756Hi,
Unfortunately, this will require significant amount of modification that is not included in the scope of support. You can hire a freelance developer or contact our partner Codeable for this kind of customization.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.