Categories
CMS Mastering Development Wordpress

WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC

I’m trying to set up a query for an “event” custom post type that groups posts by year, with a heading for each year, in descending order; then, for each year group, ordered by date in ascending order like so: 2020 Jan 1, 2020 Feb 1, 2020 Mar 1, 2020 2019 Jan 1, 2019 Feb […]

Categories
CMS Mastering Development Wordpress

WP_Query inside foreach loop returning same value for all options when filtered using ajax

I am trying to build a timetable to display classes by time. I have a taxonomy of Day, which I am looping over to create a column for each day of the week. In side the column is a WP_Query which filters using the day taxonomy and meta_key classes_entry_start_time to orderby meta_value_num. The timetable is […]

Categories
CMS Development Wordpress

meta_query check multiple date formats

I am trying to query a custom post type that has a meta value (DATE) that are equal or greater than today. My issue is that some posts have the date stored in the “Ymd” format and others have “Y-m-dTg:i a”. This is what I currently have. It currently isn’t ordering properly. ‘posts_per_page’ => -1, […]

Categories
CMS Development Wordpress

How to sort by a custom “text” date field in mmddyyyy format

I’m having issues sorting by a custom date field on my WordPress website. I’m not a WordPress coder by any means, and i’m working with a previous owner’s code. Basically the field is an ACF text field that a user enters a date into (mm/dd/yyyy format). I’m able to sort them, but they are sorting […]

Categories
CMS Development Wordpress

tax_query and sort by meta_key – no results

I have query: $tax_query = array( ‘relation’ => ‘AND’); $tax_query[] = array( ‘taxonomy’ => ‘kategoria’, ‘field’ => ‘id’, ‘terms’ => $term->term_id, ); if($_GET[‘kolor’]) { $tax_query[] = array(‘taxonomy’ => ‘kolor’, ‘field’ => ‘slug’, ‘terms’ => $_GET[‘kolor’]); } $query = new WP_Query( array( ‘post_type’ => ‘produkt’, ‘posts_per_page’ => 1000, ‘tax_query’ => $tax_query, ) ); And this works […]

Categories
CMS Development Wordpress

WP_Query sort using multiple numeric meta values

I’m trying to sort custom posts using multiple numeric meta values but I only has success when sorting with just a single meta key. In resume, I’ve two numeric meta keys pwa_score and installs. I need to order the results fisrt by pwa_score and second by installs, both in descending order. The code bellow works […]

Categories
CMS Development Wordpress

Modifying category order

I am working with a directory style wordpress theme that displays categories in masonry style columns with their posts listed under each category title. The categories are appearing on the front page in alphabetical order and I would like to change this preferably using advanced custom fields. I have managed to control the post order […]

Categories
CMS Development Wordpress

Convert a string into a decimal number for use in query

I have a meta box where a ‘Case Result’ CPT can be assigned a monetary value (e.g. $60 Million). I need to convert this into a decimal number for use as the meta_key in WP_Query. I understand how to do the reverse (https://www.php.net/manual/en/function.number-format.php#89888), but want to know if there’s a reasonable approach to taking the […]

Categories
CMS Development Wordpress

Sort custom post type by most current date picker

I’m trying to sort custom post type made with ACF plugin by most current date. Ideally future most current post should be first. Currently, I’m sorting by date, which gives me the earliest post as the first post. Here is my code. $loop = new WP_Query( array( ‘post_type’ => ‘events’, ‘posts_per_page’ => -1, ‘meta_key’ => […]

Categories
CMS Development Wordpress

Sort custom post type by most current date picker

I’m trying to sort custom post type made with ACF plugin by most current date. Ideally future most current post should be first. Currently, I’m sorting by date, which gives me the earliest post as the first post. Here is my code. $loop = new WP_Query( array( ‘post_type’ => ‘events’, ‘posts_per_page’ => -1, ‘meta_key’ => […]