Easy way to count related posts

Support MB Relationships Easy way to count related postsResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #36986
    John RoodJohn Rood
    Participant

    Is there an easier way to count the related posts than running a query to get the relationship then looping through all of the related posts? We want to do this in a few places, and we're concerned about the performance of running a query every time we want to count the posts.

    For context, this would be used in a scenario similar to the following:

    [Relationship is Listings to Offers, both CPTs]

    Listing Archive Page:

    Listing 1

    • Name
    • Price
    • Location
    • Number of Offers (Relationship)

    Listing 2

    • Name
    • Price
    • Location
    • Number of Offers (Relationship)

    Listing 3

    • Name
    • Price
    • Location
    • Number of Offers (Relationship)
    #37001
    Long NguyenLong Nguyen
    Moderator

    Hi John,

    You still need to create a query to count the number of posts. In any way, the query is the root method to count/fetch posts.

    #37212
    John RoodJohn Rood
    Participant

    Okay, thank you for the insight!

    #40907
    Igor JakubowskiIgor Jakubowski
    Participant

    Ok, so how do you do it?
    I'm working on real estate website. It's built on Oxygen builder. So I can use repeater or metabox views (prefer the repater). I've got "People" assigned to "Properties". What I need to query is count of assigned properties to particular person.

    Thanks.

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