Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    It is possible to search by both date and price, however developing code that will do this will require some rather advanced WP_Query API knowledge as first you will need to add new search field to the Adverts Search form and then customize WP_Query params to filter ads by date / price.

    The whole code will be similar to search by category https://github.com/simpliko/wpadverts-snippets/blob/master/search-by-category/search-by-category.php

    Thread Starter alex46

    (@alex46)

    Can you could help me please? I’m trying without success to add Data and Price filter to search form..

    1) I add in defaults.php in search form, new 2 arrays price_desc and price_asc..

    2o) in shortcode.php i add

    if($price_desc) {$meta[] = array(‘key’=>’adverts_price’,
    ‘orderby’ =>’date’ ,
    ‘order’=> ‘DESC’);
    }

    if($price_asc) {$meta[] = array(‘key’=>’adverts_price’,
    ‘orderby’ =>’date’,
    ‘order’=> ‘ASC’);
    }

    in form_search show two radio options but query don’t do correctly…

    Thread Starter alex46

    (@alex46)

    I add this in form_search (in defaults.php)

    ,array(
    “name” => “price_desc”,
    “type” => “adverts_field_radio”,
    “order” => 20,
    “label” => __( “PRE?O”, “adverts” ),
    “options” => array(“value”=>”DESC”, “text”=>”Descendente”),

    “meta” => array(
    “search_group” => “visible”,
    “search_type” => “half”
    )
    ),array(
    “name” => “price_asc”,
    “type” => “adverts_field_radio”,
    “order” => 20,
    “label” => __( “PRE?O”, “adverts” ),
    “options” => array(“value”=>”ASC”, “text”=>”Ascendente”),

    “meta” => array(
    “search_group” => “visible”,
    “search_type” => “half”
    )

    Plugin Author Greg Winiarski

    (@gwin)

    You should not be doing this is WPAdverts files but rather create a new plugin and update form structures using filters like in the example code i linked to in last message.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘search form with date’ is closed to new replies.