Are ‘Movie Trailer’ and ‘Movie Hub’ the names of custom post types?
Because cpt can not contain capital letters or spaces and name parameter of connection type either.
Cpts name should be some like ‘movie_trailer’ and ‘movie_hub’. Connection name some like ‘movie_trailer_to_movie_hub’.
I tried ‘movie_trailer_to_movie_hub’ too.
Here is my functions code for post type (just for movie trailers)
// registration code for movietrailers post type
function register_movietrailers_posttype() {
$labels = array(
'name' => _x( 'Movie Trailers', 'post type general name' ),
'singular_name' => _x( 'Movie Trailer', 'post type singular name' ),
'add_new' => _x( 'Add New', 'Movie Trailer'),
'add_new_item' => __( 'Add New Movie Trailer '),
'edit_item' => __( 'Edit Movie Trailer '),
'new_item' => __( 'New Movie Trailer '),
'view_item' => __( 'View Movie Trailer '),
'search_items' => __( 'Search Movie Trailers '),
'not_found' => __( 'No Movie Trailer found' ),
'not_found_in_trash'=> __( 'No Movie Trailers found in Trash' ),
'parent_item_colon' => ''
);
$taxonomies = array();
$supports = array('title','editor','author','thumbnail','excerpt','custom-fields','comments','revisions');
$post_type_args = array(
'labels' => $labels,
'singular_label' => __('Movie Trailer'),
'public' => true,
'show_ui' => true,
'publicly_queryable'=> true,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'movie_trailer', 'with_front' => false ),
'supports' => $supports,
'menu_position' => 5,
'menu_icon' => 'http://trailernerd.com/gurus/wp-content/uploads/2012/07/movies1.jpg',
'taxonomies' => $taxonomies
);
register_post_type('movietrailers',$post_type_args);
}
Plugin Author
scribu
(@scribu)
Your CPT name is ‘movietrailers’. That’s what you should pass to p2p_register_connection_type().
Ok, I changed it to the following:
function my_connection_types() {
// Make sure the Posts 2 Posts plugin is active.
if ( !function_exists( 'p2p_register_connection_type' ) )
return;
p2p_register_connection_type( array(
'name' => 'movietrailers_to_moviehubs',
'from' => 'movietrailers',
'to' => 'moviehubs'
) );
}
add_action( 'wp_loaded', 'my_connection_types' );
?>
But it still comes up as
“Movie Trailer_to_Movie Hub Posts ↔ Posts (Connected Posts)”
Hmmmm