Support » Plugin: Posts 2 Posts » Retaining connected post info

  • I found this plugin from a post on WPMU. I have to say, this is turning out to be pretty awesome.

    In my setup, I have two post types: Services and Locations. Each service is linked to several different locations. My setup can be seen here.

    In the content for the services, I’d like to use a shortcode that I’ve created, that would essentially display the location. But I’m having trouble trying to figure out how to use the p2p relationship to retain the location that was queried.

    On the above mentioned example, if I were to click on “Abbott, CA”, I can see all the services connected to that location. Clicking on a service, I’m taken to the service post. In the content of that post I’d like to be able to use “Abbott, CA”…even if this wasn’t a shortcode and it was just some <php> in the content, I’m still stuck on how to accomplish this.

    Any thoughts? TIA!

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

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

    (@scribu)

    This sounds like a job for the [p2p_connected] shortcode:

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

    I missed that in the documentation, my apologies. At quick glance and implementation, it seems that the shortcode just dumps out all connected locations of my service post. Is there a way to filter that output to only show the one location that was queried? Hopefully that’s not too confusing.

    Thanks for that fast response!

    Plugin Author scribu

    (@scribu)

    Is there a way to filter that output to only show the one location that was queried?

    You need to store which location was queried, either by passing it as a URL parameter or saving it in a cookie.

    Either way, you’ll need to write some custom PHP code.

    I can’t seem to find much on the topic. Is the post 2 post relationship using a query? How might I reference that queried object. With something like get_queried_object()?

    Pardon my ignorance, I’m not great with PHP and am learning on the fly. I’d be happy to donate or pay for your assistance in helping me figure this out.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Retaining connected post info’ is closed to new replies.