• Resolved jtredway

    (@jtredway)


    I’ve run into a problem trying to connect pages to custom post types. Whenever I use the following code, the meta box is available in the admin and it successfully searches for posts. However, it does not limit the search to only the custom post type. Moreover, it fails to save the connection.

    $args = array(
    	'from' => 'page',
    	'to' => 'promo',
    	'reciprocal' => false,
    	'title' => 'Attach Promotions'
    );

    Full code snippet at https://pastebin.com/5Ndt2HNL

    However, if I change my code to the following (a page to post connection), then not only does it save the connections, but it also shows all the connections that I tried to make with the page to promo connection.

    $args = array(
    	'from' => 'page',
    	'to' => 'post',
    	'reciprocal' => false,
    	'title' => 'Attach Posts'
    );

    Full code snippet at https://pastebin.com/pdKDuKGR

    Any ideas why?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author scribu

    (@scribu)

    Try the development version (0.7-alpha).

    Thread Starter jtredway

    (@jtredway)

    Thanks for the dev version. I like the new UI.

    However, it did not solve my problem. The new Recent button correctly pulls the promo custom post type, but the search field is only querying posts and pages.

    Thread Starter jtredway

    (@jtredway)

    I solved the problem. It had nothing to do with your plugin (which is a sweet plugin I must add).

    The problem stemmed from a search filter I wrote to to exclude certain custom post types from user search queries.

    If only I would have recognized this earlier, it would have saved me hours of SQL sniffing and debugging.

    Plugin Author scribu

    (@scribu)

    Yeah, the Recent button uses get_posts(), with filters suppressed.

    Good to hear you sorted it out.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Posts 2 Posts] Connecting to Custom Post Type fails’ is closed to new replies.