• Resolved letusrise

    (@letusrise)


    Good day! I have a question regarding about multiple connections between multiple post types upon querying them.

    Lets say, I have:
    Post Type: A
    Post Type: B
    Post Type: C

    and my Posts-to-Posts Relationship Connection:
    #1 – Post Type A to Post Type B
    #2 – Post Type A to Post Type C
    #3 – Post Type B to Post Type C

    My idea for querying their relationship is this.

    FIRST QUERY: (stored an array of ids to a variable)
    I first use the #2 connection and query all post that is related to Post Type A to Post Type C, (1 post of Post Type A and get multiple post of Post Type C related to A). I would have multiple Post Type C post and store them in array for the next query to be used.

    Nested Query:
    SECOND QUERY:
    After that, I use connection #1 to get posts of Post Type B that is connected to Post Type A (1 post of Post Type A or single Post Type A).

    THIRD QUERY: (used the variable from the result of the FIRST QUERY.)
    This is nested query with the previous query, getting a relationship from Post Type B and C using the #3 connection. Then, check if the array with stored in the first query is related to the results from third query. (Using If statements) – Finally, displaying the results.

    Is this the right one for getting their relationship?
    If this is not an efficient idea, can you share your alternative way of doing it?

    Thanks and God Bless! 🙂

    http://ww.wp.xz.cn/extend/plugins/posts-to-posts/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Posts 2 Posts] Querying Efficiency Question’ is closed to new replies.