Custom Search
-
I got 2 issues:
1. I’m not able to load multiple Datasources
2. I got a field on a form which has the name “Zoll”. I manage to get the select field and the options into it, but with the search I’m fully failing. Whats wrong?add_action( "init", "register_data_source" ); function register_data_source( ) { wpadverts_custom_fields_register_data_source( array( "name" => "DBET", "title" => "ET", "callback" => "data_source_function_et" ), array( "name" => "DBZoll", "title" => "Zoll", "callback" => "data_source_function_zoll" ), array( "name" => "DBLK", "title" => "LK", "callback" => "data_source_function_lk" ) ); } function data_source_function_et() { $et_array = array(); $i = -10; while($i<=70){ array_push($et_array, array( "value" => $i, "text" => "ET ".$i, "depth" => 0, )); $i++; } return $et_array; } function data_source_function_zoll() { $zoll_array = array(); $i = 13; while($i<=25){ array_push($zoll_array, array( "value" => $i, "text" => "$i\"", "depth" => 0, )); $i++; } return $zoll_array; } function data_source_function_lk() { $lk_array = array(); $lockreis = expode(';','3x112;3x98;4x95.25;4x95.3;4x98;4x100;4x101.6;4x108;4x110;4x114.3;4x115;4x137;4x144;4x156;5x98;5x100;5x105;5x108;5x110;5x112;5x114.1;5x114.3;5x115;5x118;5x120;5x120.6;5x120.65;5x127;5x130;5x139.7;5x150;5x160;5x165.1;6x114.3;6x115;6x120;6x125;6x127;6x130;6x132;6x135;6x139.7;6x205'); foreach($lochkreis as $lk){ array_push($lk_array, array( "value" => $lk, "text" => $lk, "depth" => 0, )); } return $lk_array; } //SEARCH BY ET //add_filter( 'adverts_form_load', 'search_by_et_form_load' ); function search_by_et_form_load( $form ) { if( $form['name'] != 'search' ) { return $form; } $form['field'][] = array( "name" => "ET", "type" => "adverts_field_select", "order" => 20, "label" => __("ET", "adverts"), "max_choices" => 5, "options" => data_source_function_et(), "meta" => array( "search_group" => "visible", "search_type" => "full" ) ); return $form; } //SEARCH BY ZOLL add_filter( 'adverts_form_load', 'search_by_zoll_form_load' ); function search_by_zoll_form_load( $form ) { if( $form['name'] != 'search' ) { return $form; } $form['field'][] = array( "name" => "Zoll", "type" => "adverts_field_select", "order" => 20, "label" => __("Zoll", "adverts"), "max_choices" => 1, "options" => data_source_function_zoll(), "meta" => array( "search_group" => "visible", "search_type" => "full" ) ); return $form; } add_filter( 'adverts_list_query', 'search_by_zoll_query' ); function search_by_zoll_query( $args ) { if( ! adverts_request( "Zoll" ) ) { return $args; } $args["tax_query"] = array( array( 'taxonomy' => 'Zoll', 'field' => 'term_id', 'terms' => adverts_request( "Zoll" ), ), ); return $args; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Search’ is closed to new replies.