• Resolved sstasio

    (@sstasio)


    Hi all,

    I’ve got my posts connected to a custom post type called destination. When a post is written, I’d like the author to assign it to a destination. The problem is that the search brings up all slugs, regardless of the connection set, that match the term while listing the connected ‘posts’ respects the connection. Have I set up my connection incorrectly, or is this a known issue when using the search? Any help is greatly appreciated. Here is my connection code:

    //Posts 2 Post Connections
    function my_connection_types() {
    	// Make sure the Posts 2 Posts plugin is active.
    	if (!function_exists('p2p_register_connection_type'))
    		return;
    
    	//events
    
    		p2p_register_connection_type( array(
    			'id' => 'event_destination',
    			'from' => 'event',
    			'to' => 'destination',
    			'sortable' => 'any'));		
    
    		p2p_register_connection_type( array(
    			'id' => 'event_recprogram',
    			'from' => 'event',
    			'to' => 'recprogram',
    			'sortable' => 'any'));
    
    		p2p_register_connection_type( array(
    			'id' => 'event_project',
    			'from' => 'event',
    			'to' => 'project',
    			'sortable' => 'any'));
    
    	//posts
    
    		p2p_register_connection_type( array(
    			'id' => 'post_destination',
    			'from' => 'destination',
    			'to' => 'post',
    			'sortable' => 'any'));	
    
    		p2p_register_connection_type( array(
    			'id' => 'post_recprogram',
    			'from' => 'post',
    			'to' => 'recprogram',
    			'sortable' => 'any'));
    
    		p2p_register_connection_type( array(
    			'id' => 'post_project',
    			'from' => 'post',
    			'to' => 'project',
    			'sortable' => 'any'));	
    
    	//people
    
    		p2p_register_connection_type( array(
    			'id' => 'employee_manager',
    			'from' => 'employee',
    			'to' => 'employee',
    			'cardinality' => 'one-to-many',
    			'sortable' => 'any',
    			'title' => array( 'from' => 'Manages', 'to' => 'Managed by' )));
    
    	//managed
    
    		p2p_register_connection_type( array(
    			'id' => 'recprogram_managers',
    			'from' => 'employee',
    			'to' => 'recprogram',
    			'sortable' => 'any'));
    
    		p2p_register_connection_type( array(
    			'id' => 'project_manager',
    			'from' => 'project',
    			'to' => 'employee',
    			'cardinality' => 'many-to-many',
    			'sortable' => 'any',
    			'title' => array( 'from' => 'Project Manager', 'to' => 'Projects Managed')));
    
    		p2p_register_connection_type( array(
    			'id' => 'destination_manager',
    			'from' => 'destination',
    			'to' => 'employee',
    			'cardinality' => 'many-to-many',
    			'sortable' => 'any',
    			'title' => array( 'from' => 'Destination Manager', 'to' => 'Destinations Managed')));
    
    			}
    
    add_action( 'init', 'my_connection_types', 100 );

    http://wordpress.org/extend/plugins/posts-to-posts/

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

    (@scribu)

    So what you’re saying is that, in the ‘event_destination’ metabox, when you search for a destination, you get posts that are not destinations at all.

    And this happens for all the P2P metaboxes?

    Thread Starter sstasio

    (@sstasio)

    Yes, that is correct. I haven’t tested all of the connections that I made, but will do so now. I’ll post the results shortly. Thanx for your awesome plugin!

    Sean

    Thread Starter sstasio

    (@sstasio)

    Scribu,

    Yes, all metaboxes produce the same behavoir.

    Sean

    Plugin Author scribu

    (@scribu)

    Can’t reproduce using the latest version (1.1.2).

    Try switching to the default theme. Then, try disabling all other plugins.

    Thread Starter sstasio

    (@sstasio)

    I figured it out, I used the following code to add my custom post types to search:

    //Add Custom Post Types to Search
    //function filter_search($query) {
    //    if ($query->is_search) {
    //	$query->set('post_type', array('post', 'employee', 'project', 'recprogram', 'partner', 'destination', 'event'));
    //    };
    //    return $query;
    //};
    //add_filter('pre_get_posts', 'filter_search');

    oops…

    I had the same problem and solved by adding a ! is_admin conditional to the if statement.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Posts 2 Posts] Metabox search not respecting connection’ is closed to new replies.