Support

Account

Home Forums General Issues Relationship: Pull in comments to related posts?

Helping

Relationship: Pull in comments to related posts?

  • Scenario: The post “Jimmy” is related to “Jimmy’s Masterpiece Project” with a many:many relationship.

    “Jimmy’s Masterpiece Project” has a bunch of comments. I want to show the comments on “Jimmy’s Masterpiece Project” on the post “Jimmy.”

    In other words, I want to pull in the posted from the RELATED post.

    So, if somebody posts a comment on url.com/jimmys-masterpiece that some comment will be pulled into url.com/jimmy.

    Is this possible?

  • See get_comments(), WP_Comment_Query and pre_get_comments

    Basically what you need to do here is to create a pre_get_comments filter that adds the post ID’s for related posts to the “post_in” argument of the comment query.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.