Skip to content

Instantly share code, notes, and snippets.

@surefirewebserv
Created October 2, 2015 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surefirewebserv/4f9679a3d19ea0e454e6 to your computer and use it in GitHub Desktop.
Save surefirewebserv/4f9679a3d19ea0e454e6 to your computer and use it in GitHub Desktop.
Sample Set Up with Multiple Relationships
<?php
// Don't copy the php tag above.
function sfws_books_to_relationship() {
p2p_register_connection_type( array(
'name' => 'bookes_to_authors', //Give it a name that you can reference
'from' => 'books', // This can be the slug name of your CPT as well
'to' => 'authors' // This can be the slug name of your CPT as well
) );
p2p_register_connection_type( array(
'name' => 'bookes_to_illustrators', //Give it a name that you can reference
'from' => 'books', // This can be the slug name of your CPT as well
'to' => 'illustrators' // This can be the slug name of your CPT as well
) );
p2p_register_connection_type( array(
'name' => 'bookes_to_publishers', //Give it a name that you can reference
'from' => 'books', // This can be the slug name of your CPT as well
'to' => 'publishers' // This can be the slug name of your CPT as well
) );
}
add_action( 'p2p_init', 'sfws_books_to_relationship' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment