Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › terms filter on custom page
- This topic has 28 replies, 2 voices, and was last updated 1 year, 4 months ago by
Ernest Marcinko.
-
AuthorPosts
-
January 17, 2025 at 10:51 am #52518
Ernest Marcinko
KeymasterSure!
You could create a hidden filter, with this exact configuration, as well as make sure this option is turned off. That will make sure that the plugin returns only items where the expiration_date field exists and is greated than 0.
January 21, 2025 at 6:25 pm #52569gavriel_wtTj
Participantdo you think this is possible?
January 22, 2025 at 8:15 am #52573gavriel_wtTj
Participantsorry, didnt see you replied as it was on page 2 😉
i just tried your set but it’s not working 🙁 Could it be because my field is a timestamp and it’s checking against the value 0?
January 22, 2025 at 8:51 am #52576Ernest Marcinko
KeymasterIf the operator (6) is set to “MORE THEN”, then it should be okay, as it checks if the value is above 0 – so make sure that is set correctly, it’s very important.
January 22, 2025 at 10:49 am #52578gavriel_wtTj
Participantyes i have set it as you mentioned . see attached image
could it have anything to do with the fact that this is a jetengine metafield?
January 22, 2025 at 2:15 pm #52584Ernest Marcinko
KeymasterIt shouldn’t make a difference. If the field value is indeed a timestamp (number), then it should be just fine. What exactly happens, you get no results after adding the filter?
January 22, 2025 at 3:28 pm #52587gavriel_wtTj
Participantdosnt seem like it does anything. I still get the results of old products that have the expiration_date in the past (see screenshot)
January 23, 2025 at 8:27 am #52593Ernest Marcinko
KeymasterMy mistake – I completely missunderstood your query here. I thought that the field was something different, I’m very sorry.
In this case it is possible, but instead of the hidden filter, you will need to use a datepicker filter, so this configuration: https://i.imgur.com/VDLd5pB.png
Don’t worry, the filter does not have to be visible, it will still work. This should do the trick, if the field is indeed a timestamp.
January 23, 2025 at 8:36 am #52594gavriel_wtTj
ParticipantGood morning
see attached screenshot. I just tried with this custom field setup and this works. But i would have to show the settings and one has to click on it to make it work.So i tried with adding 1737621233 in the hidden value (when using the hidden field setup) and this works.. which makes sense as 0 is the 1970 🙂 and i want to show events with expiration more or equal that TODAY. Do you have any macro that I can add to the value field for today/current datetime?
January 23, 2025 at 8:39 am #52596Ernest Marcinko
KeymasterSure! You can try this:
add_filter('asp_query_args', function ( $args, $search_id, $options ) { $args['post_meta_filter'][] = array( 'key' => 'expiration_date', 'value' => time(), 'operator' => '>', 'allow_missing' => true, ); return $args; }, 10, 3);You can set the ‘allow_missing’ to false if you want to exclude items where the expiration_date field does not exist 🙂
January 23, 2025 at 11:20 am #52605gavriel_wtTj
Participantbeautiful! that seems to have done the trick
this will work on any filter now . .right?
January 23, 2025 at 2:08 pm #52606Ernest Marcinko
KeymasterYes, this should work with any filter now.
January 23, 2025 at 2:10 pm #52607gavriel_wtTj
Participantgreat. Ernest, i really want to thank you for the top support!!
January 23, 2025 at 2:10 pm #52608Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.