Posts 2 Posts
[resolved] P2P incompatibility problem with Relevanssi, proposing 'solution' (8 posts)

  1. Ruud Laan
    Posted 3 years ago #

    Hi Scribu,

    I ran into a incompatibility issue with your ajax_search in the P2P_Box and Relevanssi (a search plugin). They just don't play nice together.
    Mikko (author of Relevanssi) suggested I looked into options to exclude using the Relevanssi plugin in this particular case.
    So I proposed a filter for his plugin.
    See: http://wordpress.org/support/topic/ajax-search-from-p2p_box-broken-fix for details

    However.. in order to get it working I need a distinct identifier in the query to be able to do the filtering.. I hardcoded it for now:
    in side.php:

    function do_query( $args ) {
    		$args['query_origin'] = 'p2p_plugin';
    		return new WP_Query( $args );

    Perhaps this should be a filter? and then again, perhaps your plugin could work together with Relevanssi after all? I'm still in the dark why it isn't working.

    Best regards,


  2. scribu
    Plugin Author

    Posted 3 years ago #

    There's already a 'p2p:context' variable passed which could be used to single out the query.

  3. Ruud Laan
    Posted 3 years ago #

    That's great... however the admin_box ajax search uses a different function which doesn't add this variable.. how about this to get this variable also in place for ajax searches (line 166 box.php):

    protected function post_rows( $current_post_id, $page = 1, $search = '' ) {
    		$extra_qv = array_merge( self::$admin_box_qv, array(
    			'p2p:context' => 'admin_box_ajax_search',
    			'p2p:search' => $search,
    			'p2p:page' => $page,
    			'p2p:per_page' => 5
    		) );
  4. Ruud Laan
    Posted 3 years ago #

    or just 'p2p:context' => 'admin_box'
    like in your render() method?

  5. scribu
    Plugin Author

    Posted 3 years ago #

  6. Ruud Laan
    Posted 3 years ago #


  7. Per Wiklander
    Posted 3 years ago #

    @ruud@joyo Have you got it working now? Which versions of Relevanssi and Posts2Posts are you running?

    I can run Relevanssi 2.9.14 and P2P 1.5.2 with no problems. I guess the problems in Relevanssi were introduced somewhere in the 3.0 branch.

  8. Ruud Laan
    Posted 3 years ago #

    Yes it works for me fine. I'm using the latest version of Relevanssi and P2P.
    You can use this filter to use both Relevanssi in the admin and have the search in P2P still working OK:

    add_filter( 'relevanssi_admin_search_ok', 'yourname_relevanssi_admin_search_ok_filter', 10, 2);
    function yourname_relevanssi_admin_search_ok_filter( $admin_search_ok, $query ) {
    	if ( isset( $query->query_vars['p2p:context']) && $query->query_vars['p2p:context'] == 'admin_box_candidates' ) {
    		$admin_search_ok = false;
    	return $admin_search_ok;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic