Support » Plugin: Posts 2 Posts » P2P incompatibility problem with Relevanssi, proposing 'solution'

  • Resolved Ruud Laan


    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: 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,

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


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

    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
    		) );

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

    Plugin Author scribu



    @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.

    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;
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘P2P incompatibility problem with Relevanssi, proposing 'solution'’ is closed to new replies.