We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
The text was updated successfully, but these errors were encountered:
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.
Sorry, something went wrong.
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
p2p_admin_box_show
<?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 );
No branches or pull requests
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.
The text was updated successfully, but these errors were encountered: