Open nunospot opened 6 years ago
Did you ever end up figuring out if this was possible? I just inherited a project using this plugin and need to accomplish something similar.
No. This was a "nice to have" thing :\
I don't think you can restrict the actual connection to a specific page template, but you can only show the p2p interface on certain templates using the p2p_admin_box_show
filter: https://github.com/scribu/wp-posts-to-posts/wiki/Actions-and-filters
<?php
function restrict_p2p_box_display( $show, $ctype, $post ) {
if ( 'posts_to_pages' == $ctype->name && 'to' == $ctype->get_direction() ) {
return ( 'YOUR-TEMPLATE.php' == $post->page_template );
}
return $show;
}
add_filter( 'p2p_admin_box_show', 'restrict_p2p_box_display', 10, 3 );
Hello,
Is there a way to register a post type to a specific template page?
Example:
function connection() { p2p_register_connection_type( array( 'name' => 'connection', 'from' => get_page_template('the_template.php'), //the page template 'to' => 'the_post_type' ) ); }
Connect a post type "the_post_type" to the pages that have the "the_template.php" template?
Thank you.