Tagged: ,

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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 much

    #1306867

    Hey 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,
    Ismael

    #1306895

    Hi,
    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.
    Thanks

    #1307089

    Hi,

    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,
    Ismael

    #1307094

    Thanks

    #1307394

    Hi,

    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,
    Ismael

    #1307412

    Hi,
    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”.

    #1307671

    Hi,

    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#L1088

    The related posts section are already queried by date but it fetches all related posts from the top irregardless of the current post.

    Best regards,
    Ismael

    #1308292

    Thank 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 you

    #1308459

    Hi,

    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,
    Ismael

    #1308471

    Hi,
    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

    #1308756

    Hi,

    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

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.