Forums Forums Search & Filter Pro Hide posts if nothing found

Viewing 10 posts - 21 through 30 (of 31 total)
  • Trevor
    #169248

    Regarding datetime, this is what I meant by “This is not a current feature of the plugin, sorry.”

    I myself have wanted this before, but it is not possible within the plugin.

    You could probably add it using code with the Edit Query Arguments filter:

    https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Edit_Query_Arguments

    Anonymous
    #169305

    I have tried, it’s not working. Maybe there is a mistake? I although don’t see any possibility in admin-panel to add relation ‘or’ to meta_query.

    function add_query_args($query_args, $sfid) {
            if ($sfid == 218) {
                date_default_timezone_set('Europe/Kiev');
                $now = date('Y-m-d H:i:s');
                $query_args = array(
                    'meta_query' => array(
                        'relation' => 'OR',
                        array(
                            'key'       => 'event-date-time-start',
                            'compare'   => '>=',
                            'value'     => $now,
                            'type'      => 'DATETIME',
                        ),
                        array(
                            'key'       => 'event-date-time-finish',
                            'compare'   => '>=',
                            'value'     => $now,
                            'type'      => 'DATETIME',
                        ),
                    ),
                );
            }
            
            return $query_args;
        }
    
        add_filter('sf_edit_query_args', 'add_query_args', 20, 2);
    Trevor
    #169307
    This reply has been marked as private.
    Trevor
    #169310

    I did forget to confirm, but the above code, you DID use that in the theme functions.php file, yes?

    Anonymous
    #169312

    yes, of course

    Anonymous
    #169314

    I have solved my problem with custom display results method, problem was in my template on line 93, after removing it everything works. I hope you’ll help me to find an answer about datetime and relation ‘or’

    Ross Moderator
    #169717

    Hi there, Trevor has asked me to take a look at this.

    In regards to post meta relation, do you mean this is not working when using our filter sf_edit_query_args?

    We actually pass those arguments, to a new WP_Queryhttps://codex.wordpress.org/Class_Reference/WP_Query

    Why not try creating your own custom new WP_Query (to make sure your date meta query works as expected first), and then try to apply that to the S&F query using our filter?

    Thanks

    Anonymous
    #172216

    Hello, of course I have checked my wp_query out of the plugin. It works correctly. Can you look at my example and check for mistakes or better get me a real example how can I update plugins wp_query args with my meta_query with relation ‘or’ and datetime type. Thanks

    Ross Moderator
    #172232
    This reply has been marked as private.
    Anonymous
    #172607

    I have checked everything one more time and finally decided to remove my search and filter form and created new one. After this seems like everything works. I think it was cache.

Viewing 10 posts - 21 through 30 (of 31 total)