Skip to content

Instantly share code, notes, and snippets.

View undfine's full-sized avatar

Dustin W undfine

  • Wilmington, NC
View GitHub Profile
@undfine
undfine / pods_orderby_meta_value_num.php
Last active April 19, 2024 14:55 — forked from logoscreative/functions.php
Pods Shortcode orderby 'meta_value_num'
<?php
/**
* WordPress stores all meta fields as strings, which causes problems for ordering by numbers. When using Pods::find() directly, this issue can be addressed by casting the field as a decimal, as shown here: https://github.com/pods-framework/pods-code-library/blob/master/example/classes/Pods/find/examples/orderby-number.php
*
* In shortcodes, this strategy is not possible, as MySQL functions can not be used in the WordPress post editor. Instead, you can use the "pods_shortcode_findrecords_params" params filter, as shown below:
*/
/**
* Example to order by a price field properly.
*/