WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. kcomphlint
    Member
    Posted 2 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.

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

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

  3. kcomphlint
    Member
    Posted 2 years ago #

    Thanks!

    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".

    Thanks!

  4. scribu
    Member
    Plugin Author

    Posted 2 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

About this Topic