WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
Retaining connected post info (5 posts)

  1. NWTD
    Member
    Posted 1 year ago #

    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/

  2. scribu
    Member
    Plugin Author

    Posted 1 year ago #

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

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

  3. NWTD
    Member
    Posted 1 year ago #

    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!

  4. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. NWTD
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.