Okay
  Public Ticket #2665580
Related Posts
Closed

Comments

  •  21
    Simon started the conversation

    Hi there,

    What logic is used for related posts if a post is tagged to more than 1 category?

    Thanks, Si

  •  2,963
    Andrew replied

    Hi Simon,

    This might help:https://wordpress.com/support/related-posts/.

    Thanks.

  •  21
    Simon replied

    Sorry Andrew, I'm not sure how this applies to my question?

    Seems to be about Wordpress.com

    Si

  •  2,963
    Andrew replied

    Hi Simon,

    Related posts are posts under same category and you can use a third-party plugin to show similar posts like this one https://wordpress.org/plugins/similar-posts/

    Hope this helps.

    Regards,

  •  21
    Simon replied

    Thanks Andrew.

    My question was around posts that are tagged to more than 1 category.

    What is the logic in that case?

    And then does it take the next 3 most recent or use some other filter?

    Si

  •  2,963
    Andrew replied

    Hi Simon,

    Apologies for misunderstanding your question. When you tag a post to more than one category it will be displayed on both categories. Please correct me if I am not getting you well.

    Best regards,

  •  21
    Simon replied

    Thanks for getting back to me Andrew.

    I'll try and explain better

    So if a post is tagged to 3 different categories, what 3 related posts are shown?

    Thanks, Si


  •  21
    Simon replied

    Just checking in here to see if I can get to the bottom of this one.

    Many thanks, Si

  •  1,075
    ThemeNectar replied

    Hey Simon,

    The logic/output for the related posts is handled in the function "nectar_related_post_display" in salient/nectar/helpers/blog.php, if you'd like to examine it or copy it to your child for modification.

    It works by running a query for posts in any of the categories which are assigned to the current post being viewed. 

  •  21
    Simon replied

    Hi

    Many thanks for getting back to me.

    I'm trying to get to the bottom of the logic for that query. If a post is assigned to only 1 category, I assume it takes the next 3 most recent posts in the same category.

    But what if a post is assigned to 5 categories?

    Or does it take other factors into account - most viewed posts etc.

    Thanks for your help as always - your support is fantastic.

    Si

  •  1,075
    ThemeNectar replied

    Glad I could help, Simonsmile.png

    There are no other factors taken into consideration for the query other than the current set of categories assigned to the currently viewed post. If the post being viewed has 5 categories assigned, then the first 3 posts (by date) that exist in any of those 5 categories will be output. 

  •  21
    Simon replied

    Cool, that makes sense.

    Sorry, one more question if that is ok.

    The Yoast plug-in allows the option to make one category a 'Primary Category'. Would the 'related posts' logic then display posts from the primary category only or would the same logic apply.

  •  1,075
    ThemeNectar replied

    Unfortunately, there's no logic in place to take the primary category from Yoast settings into account - the "nectar_related_post_display" function would need to be copied into your child and modified to implement that.