Preselect Filter with Hook in WPSolr Search Page
- prakashreddy.imduriParticipant10 months, 1 week ago #34955
Hi, Is there any filter/hook to preselect the filters, as there is option but no condition to add …
prakashreddy.imduriParticipant10 months, 1 week ago #34967Okay, actually my requirement was for a clean url, with filter selected..
I found this code, but didnt see any hook to use it
[class-wpsolr-option.php]public function get_facets_items_is_default() { return $this->get_option_value( true, __FUNCTION__, self::OPTION_FACET, self::OPTION_FACET_FACETS_ITEMS_IS_DEFAULT, [] ); }
wpsolrKeymaster10 months, 1 week ago #34969You can use WPSOLR_Events::WPSOLR_FILTER_BEFORE_GET_OPTION_VALUE, which is a low level filter to capture any WPSOLR options.
private function get_option_value( $is_cached, $caller_function_name, $option_name, $option_key, $option_default = null ) { if ( ! empty( $caller_function_name ) ) { // Filter before retrieving an option value $result = apply_filters( WPSOLR_Events::WPSOLR_FILTER_BEFORE_GET_OPTION_VALUE, null, [ 'option_name' => $caller_function_name, '$option_key' => $option_key, '$option_default' => $option_default, ] ); if ( ! empty( $result ) ) { return $result; } } ... }
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.