• Resolved Andrea

    (@licoreo)


    Hello
    i have a custom post type with post that are not stored in algolia, and when i search in admin page i can’t found anything

    exists a way to disable algolia for some search?
    thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Just to be certain, are you seeing results like you’re expecting when you have Algolia search the plugin disabled?

    Thread Starter Andrea

    (@licoreo)

    yes, with disabile plugin the risulta are correct

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’ve asked our other devs around the plugin here and they’re saying it shouldn’t be affecting searching, however I am not outright dismissing what’s going on for you.

    I do know I’m seeing this which gets used a lot in the Algolia_Search class:

    /**
     * Determines if we should filter the query passed as argument.
     *
     * @author WebDevStudios <[email protected]>
     * @since  1.0.0
     *
     * @param WP_Query $query The WP_Query to check.
     *
     * @return bool
     */
    private function should_filter_query( WP_Query $query ) {
    	$should_filter = ! $query->is_admin && $query->is_search() && $query->is_main_query();
    
    	/**
    	 * Allow developers to override the return value of <code>should_filter_query()</code>.
    	 *
    	 * @since  1.3.0
    	 *
    	 * @param bool     $should_filter Whether Algolia should filter the search query.
    	 * @param WP_Query $query         The WP_Query that was tested for Algolia Search filtering.
    	 */
    	return (bool) apply_filters(
    		'algolia_should_filter_query',
    		$should_filter,
    		$query
    	);
    }
    

    I’m curious if maybe something is changing that to true in your case, perhaps?

    Thread Starter Andrea

    (@licoreo)

    now it works, the issues was caused for a my previuos function:

    public function abilita_algolia_archivi($should_filter,$query)
        {
            
            if ( !empty($query->query['s']) )
            {
                return true; 
            }
            return false;
        }

    now i edited in this way

    public function abilita_algolia_archivi($should_filter,$query)
        {
            if (is_admin())
            {
                return false;
            }
            if ( !empty($query->query['s']) )
            {
                return true; 
            }
            return false;
        }

    And it works!
    thank you for your time!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘disable algolia for some cpt’ is closed to new replies.