How do I display posts ordered by a date custom field?

I figured it out afterwards. Ended up using a different approach, I’m posting it in case someone has the same issue <?php date_default_timezone_set(‘America/Argentina/Buenos_Aires’); $posts_by_date_field = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘fecha’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_type’ => ‘DATE’ )); if ($posts_by_date_field->have_posts()) : while ($posts_by_date_field->have_posts()) : $posts_by_date_field->the_post(); // LOOP … Read more

Order WordPress Query by Custom Field While Still Using Tax_query Argument

You can use a meta_query in addition to your tax_query : https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters I have in which if statement you want to use it so I put it in the of the code. $names = array( ‘fields’ => ‘names’ ); $prac_names = get_terms(‘attorney-practice’, $names); $prac_matches = array_shift(preg_grep (‘(‘. $search .’)’, $prac_names)); $off_names = get_terms(‘office-location’, $names); $off_matches … Read more

Send default WooCommerce email when switching from custom order status

Looks like I was overcomplicating things. This is the solution: add_filter( ‘woocommerce_email_classes’, ‘custom_woocommerce_email_classes’, 10, 1 ); function custom_woocommerce_email_classes( $email_classes ) { $email_classes[ ‘WC_Email_Customer_On_Review_Request’ ] = include_once ‘includes/classes/class-wc-email-customer-on-review-request.php’; // Register custom trigger to send on-hold email when status is switched from on-review to on-hold. add_action( ‘woocommerce_order_status_on-review_to_on-hold_notification’, [ $email_classes[ ‘WC_Email_Customer_On_Hold_Order’ ], ‘trigger’ ], 10, 2 ); return … Read more

How to sort (orderby) a query done by a template function before the ‘foreach’ loop?

Without knowing what Realia_Post_Type_Property::get_properties() does and returns, this is a bit tricky to answer. But essentially, you want to to sort an array using PHP. Unless Realia_Post_Type_Property::get_properties() allows you to get a sorted list of posts, your best bet is probably to use wp_list_sort(). That function sorts a list of objects, based on one or … Read more

WP_Query: custom orderby (not ASC nor DESC)

You probably can find some way to make MySQL do the sort for you, but an alternative approach is to make it into an ASC/DESC order by adding additional meta in which you put a numeric sort order value based on whether it is apple, bag, etc and update it when the post is saved. … Read more

Using Orderby and meta_value to order natural/alphanumerical

The orderby argument is limited by what is possible in MySQL, and it’s not good at natural alphanumeric sorting like you describe. Possible options include: Rewriting the values with leading zeros, e.g. “CA05” Creating a separate “Sort Order” column that just stores an integer, and ordering by that. Separating the letters and numbers into two … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)