Plugin Author
scribu
(@scribu)
What exactly do you mean by “doesn’t work”? 0 posts found? returns random posts?
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?
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.
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.
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' );