forked from scribu/wp-posts-to-posts
-
Notifications
You must be signed in to change notification settings - Fork 3
Admin box display
scribu edited this page Apr 27, 2013
·
10 revisions
When registering a connection type, you can control if and where the connections metabox shows up in the admin:
<?php
p2p_register_connection_type( array(
'name' => 'my_connection_type',
'from' => 'page',
'to' => 'user',
'admin_box' => array(
'show' => 'any',
'context' => 'side'
)
) );Possible values for the 'show' key:
-
'any'- show admin box everywhere (default) -
'from'- show the admin column only on the 'from' end -
'to'- show the admin column only on the 'to' end -
false- don't show admin box at all
Possible values for the 'context' key:
-
'side'- show admin box in the right column -
'advanced'- show the admin box under the main content editor
By default, P2P will use the labels that the custom post type has. If you want to overwrite them, you can use the 'from_labels' and 'to_labels' parameters, like so:
<?php
p2p_register_connection_type( array(
'name' => 'users_to_stuff',
'from' => 'user',
'to' => array( 'car', 'house' ),
'title' => array(
'from' => __( 'People', 'my-textdomain' ),
'to' => __( 'Items', 'my-textdomain' )
),
'from_labels' => array(
'singular_name' => __( 'Person', 'my-textdomain' ),
'search_items' => __( 'Search people', 'my-textdomain' ),
'not_found' => __( 'No people found.', 'my-textdomain' ),
'create' => __( 'Create Connections', 'my-textdomain' ),
),
'to_labels' => array(
'singular_name' => __( 'Item', 'my-textdomain' ),
'search_items' => __( 'Search items', 'my-textdomain' ),
'not_found' => __( 'No items found.', 'my-textdomain' ),
'create' => __( 'Create Connections', 'my-textdomain' ),
),
) );