Problem: I would like to add a filter to my custom search View that has options with different price ranges. For example, Less than 50, 50 - 100, and 100+.
Solution: There is not an easy way to accomplish this in Toolset using a standard price filter. You would have to create a separate custom field that holds a value that represents each price range, then filter based on that custom field. To automate the process, you could use a hook like save_post or pmxi_saved_post to check the current price and update the value automatically:
function post_saved( $post_id, $post, $update ) { $range = 0; $price = get_post_meta( $post_id, 'wpcf-price', true); if( $price < 50000 ) { $range = 1; }else if( $price >= 50000 && $price <= 100000 ) { $range = 2; } else if( $price > 100000 ) { $range = 3; } update_post_meta( $post_id, 'wpcf-sort-price', $range); } add_action( 'pmxi_saved_post', 'post_saved',10,1);
Relevant Documentation:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
https://codex.wordpress.org/Function_Reference/update_post_meta
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 3 réponses, has 2 voix.
Last updated by Paul Il y a 5 années et 9 mois.
Assisted by: Christian Cox.