Limit Search results to a certain custom taxonomy

  • prakashreddy.imduri
    Participant
    4 weeks ago #31449

    Hi,
    I am looking to limit the search results to a custom taxonomy based on user input, any code to work it out.

    add_action( WPSOLR_Events::WPSOLR_FILTER_UPDATE_WPSOLR_QUERY, 'limit_taxonomy_search', 10, 1 );
    function limit_taxonomy_search( WPSOLR_Query $wpsolr_query ) {
    if ( 'test' === $current_keywords ) {
    	// set taxonomy restriction to current search results
    }
    }
    wpsolr
    Keymaster
    4 weeks ago #31450

    There is no way to do so with a WPSOLR hook.

    prakashreddy.imduri
    Participant
    3 weeks, 1 day ago #31481

    Okay, how can I pass on regex as a search query to match titles only, when the query matches a specific word..
    Currently, the search is happening across the title and content(custom fields), But wanted to limit to title for specific query.

    add_action( WPSOLR_Events::WPSOLR_FILTER_UPDATE_WPSOLR_QUERY, 'update_query_existing', 10, 1 );
    function update_query_existing( WPSOLR_Query $wpsolr_query ) {
    if ( 'test' === $current_keywords ) {
            if (preg_match('/^X-[a-zA-Z-]+/', $post_title)) { // checking if this condition matches, then return those results
                return the posts matching the above regex;
           }
    }
    }
    wpsolr
    Keymaster
    3 weeks, 1 day ago #31482

    There is no way to do so with a WPSOLR hook.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.