Instead of storing your values as “5 hours 13 minutes” instead store them as timestamps, e.g. 5:13 for 5h 13m
This way you can use the date/time comparator operations to answer questions
E.g. to get items under 5 hours and 30 minutes:
$args = [
...
'meta_query' => [
[
'meta_key' => 'time',
'meta_value' => date( "5:30" ),
'meta_compare' => '<',
'type' => 'TIME',
],
],
];
$query = new WP_Query( $args );
This will match a 3 hour post, or a 4:20 post, or a 5h 29min post.
You may need to add :00 for the seconds on to the end of all code and values.
For display you can use human_readable_duration. This will include the seconds though, but the function is very simple so copying and modifying it to your requirements should be straight forward.
Related Posts:
- Customised plugin failed to install and activate
- Trying to create a table/list of my EventBrite course listings [closed]
- Privileges problem with add_submenu_page [closed]
- Why is one phpunit test throwing an error on one class when all other classes are similar without error?
- WP_Http response throws “Cannot use object of type WP_Error as array”
- Modify wp_installed_email / wp_new_blog_notification
- How to get all posts belongs to a user between a certain date
- Using Variable in WordPress Translate Functions
- Plugin getting Cannot modify header information errors
- Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin
- iframe not showing in post (with “allow php in posts” plugin activated)
- how can I do something on new user registration?
- How to get plugin’s folders permission
- Add item to the woocommerce dashboard menu from a plugin
- How to remove bulk actions from custom post type
- License validate function
- Plugin for an interactive image? [closed]
- wp_enqueue_style on template_redirect level?
- Multiple authors and readers restricted by role [closed]
- CSS reset for plugin’s front end?
- getting notifications about updates only in the “core” page
- Generate Email Newsletter HTML from Posts published within a Date Range?
- Display my plugins content based on a pages post_id
- How can I get someone to checkout as soon as they add a product to cart?
- Displaying syntax highlighted code [closed]
- Categories from front-end, checkbox selection doesn’t work
- Can you echo PHP code from a variable?
- Pluging with content for a specific page or post
- save data from metabox does not work
- Share buttons Facebook Twitter, just like wordpress.com without webservice
- Strange Behavior on New Theme Points to Idiocy
- Restrict posts to customers with complete WooCommerce orders only
- WordPress not showing manually uploaded files in Uploads folder on Media Library
- Dynamic URL Rewrite for Custom
- Can’t load the the canges of field groups [duplicate]
- Disable recpacha for contact form 7 specific form
- What is com_jce
- Adding custom post category to categories widget
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Cant create table on plugin activation
- Trouble with AJAX using GET
- Why is my shortcode not working?
- Custom Rewrite Rule Removing Query String
- Import 2000 posts from one website to another
- Critical Error after Updraft Restoration
- Link custom post type to page
- How to get Angular app working in WordPress plugin?
- wp_remote_post To external API multiple values with the same key
- ” tag is changed to ” when configuring Cookie Notice
- How to add specific posts to specific pages in WordPress?
- added code to permalink (URL)
- Why is my custom taxonomy image not displaying?
- redirect to a custom page
- How to order blog posts by no. of likes?
- Set Content-Type header in do_parse_request filter
- Add section (add_settings_section) to a custom page (add_submenu_page) not working
- cURL do not mimic click
- What action or filter can I use to change all the html returned from server for a page?
- how to show Author group not Author name
- How can I display a list of only categories which are marked as ‘featured’ in the backend?
- Wordress admin page is fetching error You do not have sufficient permissions to access this page.
- Unexpected plugin_dir_path Output
- Plugin install error: Installation failed: The package could not be installed
- How to change text in a page by utilizing a custom user id?
- How can I make my plugin display custom post meta data on the front end?
- Which WordPress version to use for improved plugin compatibility? [closed]
- WP_Filesystem usage within a block of code
- Convert HTML5/CSS3 site to WordPress Theme (need a lot of plugins) or just use the API?
- Extending the “Add Media”-Dialog … how do I finally insert something to the Post?
- How can I retrieve data within my widget
- Incentive theme – Getting ’You do not have sufficient permissions’ while trying to install plugins
- Private WordPress blog, requires user registration approval, and allowing users to login with OpenID
- How do I make the selected layout display for all MarketPress pages?
- What tool are available in the wordpress API for debugging a plugin?
- In my plugin when i call select page is blank
- include plugin folder directly in theme folder to load faster page n wp
- Including a PHP file via a function that is part of a plugin?
- Twitter List Tweets and Delicious Links as Posts
- Overriding FB Auto Connect plugin function displayed in footer
- Replace all media (images)
- How do i remove “Powered by WordPress” from AMP?
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Trying to disable all notifications except for one on woocommerce checkout page with css [closed]
- How I can hide my wp folders from Inspect Element (Developer Tools)
- How to Find WordPress site has backdoor login Codes
- WordPress woocommerce shipping order [closed]
- List all posts in a particular page [closed]
- How do I set register_meta for a specific CPT?
- How to Enfroce Domain Licensing Limits? [closed]
- Override plugin constant using a theme
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Update Content for a Custom Block Toolbar Button
- Issue with customizer and widget page
- Submitting form to admin-post.php WordPress
- WordPress Throwing Deprecated Errors on its own Files
- How to update a lot of posts on my WP site with additional content?
- Changing slug when post is copied
- Show the author only own types of publications. (JetEngine, Elementor)
- use the live preview feature in the plugin
- add to cart linking to add to cart page