Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Daniel Agostinelli

Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Daniel Agostinelli in reply to:
    S&F Pro with Avada search.php
    #10087
    This reply has been marked as private.
    Daniel Agostinelli in reply to:
    Filter based on range of meta data values
    #10086

    Yep I understand, and I appreciate the help you’ve already provided! 🙂 I’ve managed to put together a working solution that allows users to select, independently, a day and a time, and then the plugin shows restaurants that are open at that day and time. Until I properly learn how to use ajax to build my own plugin, this will do 🙂

    Daniel Agostinelli in reply to:
    S&F Pro with Avada search.php
    #10049
    This reply has been marked as private.
    Daniel Agostinelli in reply to:
    Filter based on range of meta data values
    #10026

    Ok I’ve been playing around with the code you provided – it has been very helpful, both in terms of getting me to a workable solution, but also in helping me understand more about how the plugin works 🙂

    A couple of questions and comments:

    1. On the line $value = (int)$value; //cast value as a number it seems that $value is empty, because it is outside of the foreach loop where it takes values of $meta_query['values']. I’ve changed it to $value = (int)$meta_queries['values'][0]; and it seems to work.
    2. Looks like there are a couple of lines without a terminating semicolon (;). Easy fix 🙂
    3. QUESTION: I’m a little confused about the sf_meta_$meta_iter.meta_key part. With the code as you’ve written, the $where SQL clause ends up looking like the following I’ve shortened it to just show the relevant part:
      $where = "...AND ((sf_meta_1.meta_key = 'open_time') AND (sf_meta_1.meta_value <= $user_input_time))
       AND ((sf_meta_1.meta_key = 'close_time') AND (sf_meta_1.meta_value >= $user_input_time))"

      It looks like sf_meta_1.meta_key is being checked against both the “open time” and “close time” meta keys. Obviously it can’t be equal to both meta keys at the same time, so I found that the search would always return no results. Does this make sense? Is there an easy way to resolve this?

    Thanks again,
    Dan

    Daniel Agostinelli in reply to:
    S&F Pro with Avada search.php
    #9991

    Ok I’ve disabled the is_search forcing, removed the query_posts() custom query from the Avada template file and set display results to “As an archive page” with the name of the new custom template in the textbox. I’ve then inserted the [searchandfilter id="XX"] shortcode into the page that I want to use for the search. It unfortunately still doesn’t seem to work.

    Daniel Agostinelli in reply to:
    Filter based on range of meta data values
    #9981

    Thanks so much for that Ross – I really appreciate your great customer service! I am about to head off to work so I’ll have to wait until later this evening to give this a shot, but it gives me a great place to start. I’ll let you know how it goes! 🙂

    Daniel Agostinelli in reply to:
    S&F Pro with Avada search.php
    #9978

    Thanks for this Ross. I’ve tried the above (including forcing is_search to be true) however it seems that regardless of what my input to the search form is I get the “Couldn’t find what you’re looking for!” page, and the search form no longer visible.

    Daniel Agostinelli in reply to:
    Filter based on range of meta data values
    #9976

    Hi Ross, thanks for the reply.

    A range slider where the top and bottom numbers are compared against two different meta keys would work, however even simpler would be a simple single-value input field (text input? Drop down? etc.) where the single input is compared to two different meta keys.

    What I am essentially trying to do is create an “opening hours” search for a bunch of restaurants. Each of my “restaurant” posts has an “open time” meta field and a “close time” meta field. Basically I want to be able to filter by displaying only restaurants that are open at a given time.

    I inserted the above code at 95 (just above the $query = new WP_Query($args) line). Though this was more just for me to play around with the $args input to WP_query to help me understand what I can do with it (I have a little experience with PHP and WordPress, but not much). I have since removed the lines because it’s not a permanent solution.

    Daniel Agostinelli in reply to:
    Filter based on range of meta data values
    #9873

    I’ve found that I can add the following lines to class-search-filter-get-results.php to get the results that I need.

    $args['meta_query'][] = array('key'=>'field_A', 'value' => $value, 'type'=>'NUMERIC', 'compare' => '<=');
    $args['meta_query'][] = array('key'=>'field_B', 'value' => $value, 'type'=>'NUMERIC', 'compare' => '>=');

    Obviously this is a very hacked-together solution and not necessarily the solution that I want to land on. It maybe helps to demonstrate what I’m trying to achieve, however I’d still like to be able to include inputs in the search from so that the user can specify the value of $value. Although I’m not an expert, I’m relatively comfortable using PHP, so I don’t really need a full solution that modifies the admin interface – I am happy editing code if I know where I should be looking.

Viewing 9 posts - 1 through 9 (of 9 total)