bearlog
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Checkbox SearchIt works, thank you I appreciate it. your plugin is really cool!!! 5stars
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Checkbox SearchThx for answer. I try, but it still don’t work for me. Can you check please.
<?php /** Plugin Name: WPAdverts Snippets - Search by checkbox Version: 1.0 Author: Greg Winiarski Description: Adds categories dropdown input to [adverts_list] search bar. */ // The code below you can paste in your theme functions.php or create // new plugin and paste the code there. add_filter( 'adverts_form_load', 'search_by_neworused_form_load' ); add_filter( 'adverts_list_query', 'search_by_neworused_query' ); /** * Adds category dropdown into search form in [adverts_list]. * * @param array $form Search form scheme * @return array Customized search form scheme */ function search_by_neworused_form_load( $form ) { if( $form['name'] != 'search' ) { return $form; } $form['field'][] = array( "name" => "my_custom_neworused", "type" => "adverts_field_checkbox", "order" => 20, "label" => "Its new? or used?", "max_choices" => 1, "options" => array( array("value"=>"new", "text"=>"new"), array("value"=>"used", "text"=>"used"), ), "options_callback" => "adverts_taxonomies", "meta" => array( "search_group" => "visible", "search_type" => "full" ) ); return $form; } /** * Adds tax_query param to WP_Query * * The tax_query is added only if it is in $_GET['advert_category'] * * @param array $args WP_Query args * @return array Modified WP_Query args */ function search_by_neworused_query( $args ) { if( ! adverts_request( "my_custom_neworused" ) ) { return $args; } $args["tax_query"] = array( array( 'taxonomy' => 'my_custom_neworused', 'field' => 'term_id', 'terms' => adverts_request( "my_custom_neworused" ), ), ); return $args; }
Viewing 2 replies - 1 through 2 (of 2 total)