Posts 2 Posts
[resolved] Query Connection For Specific Relationship (4 posts)

  1. kcomphlint
    Posted 3 years ago #

    We would like to have the ability to supply an "if" argument in our template file so that if the page or post being viewed is related to another specific page or post, then that if argument would be triggered.

    For instance, we have a "people" post type. We have them connected to multiple pages of a "services" post type. If they are connected to service #2, then a certain piece of code would be written into the template file. If not, then it doesn't get executed.


  2. scribu
    Plugin Author

    Posted 3 years ago #

  3. kcomphlint
    Posted 3 years ago #


    So in that code, what goes in place of the $post_a and $post_b? Should that be the ID of the post we are looking at (post_ID) and the value of the post we want to check for "123"?

    Here is our connection type setup in the functions file:

    p2p_register_connection_type( array(
    		'name' => 'related_attorneys_services',
    		'from' => 'people',
    		'to' => 'services',
    		'title' => array( 'from' => 'Related Services & Industries', 'to' => 'Related Attorneys' )
    	) );

    We want to check that the "people" are related to a specific post under "services".


  4. scribu
    Plugin Author

    Posted 3 years ago #

    $post_a and $post_b can be either post IDs or post objects. Post objects is preferred.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic