Support » Plugin: Posts 2 Posts » [Plugin: Posts 2 Posts] More help with connecting posts one level apart

  • Resolved remtheory

    (@remtheory)


    Hi there! So, I’ve poured through the documentation and have continuously failed at trying different ways to get this to render. I thought perhaps the Loops page would provide some insight but I couldn’t get anything to display, which perhaps is due to my lack of understanding. So, here’s the sitch…

    I’ve got a custom post type called Products, another custom post type called Brands and another custom post type called Stores. Right now, Brands display both the products and the stores, which is great. I’ve got that working like a charm. And I’ve got products and store pages linking to their related brands. Also, lovely. But what I’d love to do is have my Product page list the related stores and standards that are attached to that product.

    Here’s my site, so you can see what I’m talking about:
    http://www.kind-eye.com/brand/100-pure/ is the brand page, looking lovely.
    http://www.kind-eye.com/product/100-pure-fruit-pigmented-eye-shadow/ is a product page, and ideally it would replicate the same information from the brand page for Store & Standards.

    Thanks for any help!

    http://wordpress.org/extend/plugins/posts-to-posts/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author scribu

    (@scribu)

    It would be useful to see your p2p_register_connection_type() calls.

    Paste them on http://gist.github.com with a link back here.

    remtheory

    (@remtheory)

    Plugin Author scribu

    (@scribu)

    For the “Other Products in This Brand” tab, you can use get_related():

    https://github.com/scribu/wp-posts-to-posts/wiki/Related-posts

    For the “Find Where to Buy” tab, you’ll first need to get the connected brand. Afterwards it’s the same code as on the brand page.

    remtheory

    (@remtheory)

    Sigh. Clearly this is beyond me, no luck in getting the “Other Products in this Brand” to work. Am I just supposed to add $related = p2p_type( ‘brand_to_product’ )->get_related( get_queried_object_id() );, or is it the whole shebang, more like https://gist.github.com/1895238?

    Plugin Author scribu

    (@scribu)

    $related = p2p_type( 'brand_to_product' )->get_related( get_queried_object_id() );

    should work. Here’s the corrected gist: https://gist.github.com/1895302

    remtheory

    (@remtheory)

    Weird, i’m just getting nothing. not even an error, just zero results. every product is definitely associated with a brand and i’ve been able to populate the brand just fine, but still no luck on the products that are connected to that brand. I’ve left my theme functions php file completely as is and am using the Allow PHP plugin to toss in the code and embed it in a template view. Maybe my plugin hackery is getting out of control?

    remtheory

    (@remtheory)

    Alrighty, apparently I had to remove some of the calls I had, which I think freaked it out. Related products appear! Onto figuring out the next chunk. Thank you sooo much!

    remtheory

    (@remtheory)

    Where’s that pesky donate button of yours so I can show you some cash love?

    Plugin Author scribu

    (@scribu)

    Just a note for anyone who happens upon this page and can’t get the solution to work for them. Make sure that if you are on a post that would be “related” in the sense that you are looking for, that there are more posts than just that one that are related. I thought the code wasn’t working but I was on the one the page for the only post that was related and of course it doesn’t show up as related so I thought it wasn’t working.

    Hope that helps somebody!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Posts 2 Posts] More help with connecting posts one level apart’ is closed to new replies.