• Resolved brightidea

    (@brightidea)


    I have multiple post types setup. Two of which are Articles and Products. I have setup a p2p connection between these. I have about 800 products and 30 something articles. After setting up the connection between two post types and then going to the backend and editing the article and trying to search from the p2p metabox for a product the search function doesnt work. I actually had everything setup and working on a different multisite installation and now after migrating the site to a different multisite installation this isnt working. Nothing else has changed. Im thinking there is a db value somewhere that wasnt updated when i made the migration.

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

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

    (@scribu)

    What exactly do you mean by “doesn’t work”? 0 posts found? returns random posts?

    Thread Starter brightidea

    (@brightidea)

    It simply says nothing found. I can click view all tab and it shows all available products. About 49 pages worth. But when i search something even if its the exact title of the product i get “Nothing Found”.

    Plugin Author scribu

    (@scribu)

    You’re not using the latest version of P2P (1.2), are you?

    Thread Starter brightidea

    (@brightidea)

    I upgraded to it and thats when i began having the problem. I did downgrade to the 1.1.5 i believe trying to diagnose problem and just havent reupgraded

    Plugin Author scribu

    (@scribu)

    Please update back to 1.2 and deactivate all other plugins.

    If the problem goes away, activate one plugin at a time, until it starts happening again.

    Thread Starter brightidea

    (@brightidea)

    ok i have reupgraded and now can see the “View all” button which i wasnt able to see before after the upgrade to 1.2. Still no results when searching for anything. Even if i copy and past a title in exactly.

    Thread Starter brightidea

    (@brightidea)

    ok i deactivated all plugins and it magically worked! of course lol. Weird thing is i actually reactivated all plugins that were previously activated and its still working great. Thanks!!

    Hi scribu,

    I’ve got same problem like this one, I try to connect between 2 post type, “article” and “company”, If I click “View All” link at edit “article” post it will show all “company” post, but if I type something in search box it’ll show all post from another post type except from “company”, this is my register script :

    http://pastebin.com/4prGR5RG

    I already try to disable all plugins and ONLY activated the Posts 2 Posts plugins but it still have same issue, I hope you can help me with this issue.

    Note : I’m using WordPress v.3.4 with WPMU enabled and p2p v.1.3.1 if that can help you with.

    Uppppssss…… I found this :

    http://wordpress.org/support/topic/plugin-posts-2-posts-metabox-search-not-respecting-connection?replies=7 and It solved my problem.

    Sorry not search all over your discussion before asking.

    Great plugins!

    Very thanks.

    Hi All,

    Just wanted to weigh in here because I figured out with the help of the questions here as well as that linked post by rolies106 that you need to be really careful when modifying the main query with WordPress. I needed to make only the blog posts show on a search (instead of all pages) so I put a filter on pre_get_posts like so:

    function searchfilter( $query ) {
    	if ( $query->is_search ) {
    		$query->set( 'post_type','post' );
    	}
    	return $query;
    }
    add_filter( 'pre_get_posts', 'searchfilter' );

    Then I’m wondering why the Search function on Posts to Posts relations isn’t working and only showing blog posts because I did this way after I set all of that up. Then it hit me: simply add the check on the if conditional !is_admin(). I did this and it’s working great again because it’s not adding this filter to any admin sections. This would also mess up ANY search functionality on the admin without that check.

    Fixed code:

    function searchfilter( $query ) {
    	if ( $query->is_search && ! is_admin() ) {
    		$query->set( 'post_type','post' );
    	}
    	return $query;
    }
    add_filter( 'pre_get_posts', 'searchfilter' );

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Posts 2 Posts] Search for Object in Connection Meta box not working’ is closed to new replies.