Help with – yith_wcan_query_vars_to_merge
-
Hi.
I need make 2 pages in store – men and women, with selection of goods by gender. On page for women – displayed only goods for woman and filter should apply this by default. I found hook in your plugin that should suit me – yith_wcan_query_vars_to_merge?/**
* APPLY_FILTERS: yith_wcan_query_vars_to_merge
*
* Filters list of query vars to add to the query. - Фильтрует список переменных запроса, которые можно добавить в запрос.
*
* @param array $query_vars List of query vars
*
* @return array
*/
$query_vars = apply_filters( 'yith_wcan_query_vars_to_merge', $this->get_query_vars() );Can you explain in what format the query parameter should be passed so that the hook works correctly?
// Insert in function.php
function modify_start_param_yith_wcan( $this->get_query_vars ) {
if ( $this->is_main_query() && $this->post_type = 'product' ) {
if(isset($_GET['female'])) {
$this->query_vars = array(
'key' => 'gender',
'value' => 'women',
'compare' => '=',
'type' => 'string'
)
}
};
return $query_vars;
}
add_filter('yith_wcan_query_vars_to_merge', 'modify_start_param_yith_wcan');Will this be correct?
Thanks in advance for your reply.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.