WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] p2p metabox disappears in 0.7 (10 posts)

  1. Israel Curtis
    Member
    Posted 3 years ago #

    I just updated to 0.7, hoping to get some of that new "sexier" metabox action, but instead, I've got no metabox showing at all ;-)

    Has something changed in 0.7 that requires some kind of manual display settings? I can see that my relationships are still active, as my custom queries are still showing related assets, but I don't even see the p2p metabox listed in the "screen options" tab...

    What would be even better would be if I could manually display the p2p metabox where I want (instead of on the right side). How could I generate it in the same "normal" column with my other custom metaboxes?

  2. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Please paste the code you're using to register the connection.

  3. Israel Curtis
    Member
    Posted 3 years ago #

    p2p_register_connection_type( array(
    	'from' => array('stills','videos'),
    	'to' => 'releases',
    ) );
  4. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Ah yes, p2p_register_connection_type() doesn't accept arrays of post types anymore. This is fixed in the development version (0.8-alpha).

    For controling where the connection box appears, you can use the 'context' arg (the default is 'side'):

    p2p_register_connection_type( array(
    	'from' => array('stills','videos'),
    	'to' => 'releases',
    	'context' => 'advanced'
    ) );
  5. Israel Curtis
    Member
    Posted 3 years ago #

    Thanks - the 0.8a fixed it.

    Context worked too, but wondering how I can change the order of metaboxes displaying - I know "normal" comes before "advanced", but I'd prefer the connection box display in a specific order, among the other metaboxes I'm creating for my custom post type. That's why I wondered if I could programmatically spawn it myself. Even better would be for me to be able to display the connection box UI components within another custom metabox I've created to display additional information about the connected posts.

    Many versions ago, I was actually able to do this by calling a p2p class directly:

    $args = array(
    	'from' => 'stills',
    	'to' => 'releases',
    	'box' => 'P2P_Box_2',
    	'title' => 'Foobar',
    	'reciprocal' => false,
    );
    $foo = new P2P_Box_Multiple($args, false, 0);

    This doesn't work anymore - is there a new way I can "inject" the connection box UI elsewhere?

  6. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    I'm afraid you're on your own there.

    If you need that much control, you're probably better off writing your own UI from scratch and using the available API to create the connections.

  7. Israel Curtis
    Member
    Posted 3 years ago #

    I have a custom post type that I'm registering with p2p, but I don't actually want to display the connection box on the edit page for that type - I only want to create p2p connections programmatically (not allow user to do so manually).

    I took a wild guess and put

    p2p_register_connection_type( array(
    	'from' => 'foo',
    	'to' => 'bar',
    	'context' => 'none'
    ) );

    in my p2p_register_connection_type.

    It seems to work - the metabox isn't showing, but am I breaking something by doing this?

  8. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    At the moment, p2p_register_connection_type() is just for creating metaboxes, so you can skip it entirely.

  9. Israel Curtis
    Member
    Posted 3 years ago #

    but if I skip it, can I still use p2p_connect() to establish the relationship?

    Somehow I thought I had to declare the relationship between types first with p2p_register_connection_type() and then p2p_connect() to create each individual connection...

  10. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Yes, you can still use p2p_connect() etc.

    As I said before, p2p_register_connection_type() is just for the UI.

    If you don't trust me on that, just look at the code. :P

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic