Articles of order

Orderby two meta fields not working

Good day. I have the following code: $args = array( ‘post_type’ => ‘property’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘rc_repl_status’, ‘field’ => ‘slug’, ‘terms’ => ‘sold’ ) ), ‘posts_per_page’ => 100, ‘meta_key’ => ‘_rc_repl_property_year_sold’, ‘orderby’ => ‘meta_value _rc_repl_property_acres’, ‘order’ => ‘DESC’ ); $query = new WP_Query( $args ); First I am filtering my post type […]

WP_User_Query orderby meta_val_num

I know that normal WP_Query’s can have an “orderby” parameter of “meta_value_num”, but when I try to user “orderby” => “meta_value_num” on a WP_User_Query, it doesn’t seem to work. Anyway I can obtain this functionality or is there something I’m missing? Edit: Here’s what I’ve tried to retrieve results ordered by numeric meta values: $sorted_users […]

WP_Query custom order and pagination

I am seeing some strange behaviour when combining a custom order with pagination when using WP_Query. The arguments for my query are as follows: $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 10, ‘meta_key’ => ‘news_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘paged’ => $my_page ); The variable $my_page contains the current page number as […]

Post ordering not working with custom field

I am trying to create an Events CPT with a widget, and can’t seem to fathom out how to get the ordering done right. My arguments that I have are: $event_args = array( ‘post_type’ => ‘event’, ‘posts_per_page’ => $count, ‘nopaging’ => true, ‘ignore_sticky_posts’ => 1, ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘wca_events_startdate’, ‘meta_value’ […]

Filtering by multiple conditions in the loop

I’m trying to filter the posts in my index by multiple conditions. So far I’ve tried with this: <?php $query = new WP_Query( array( “post__not_in” =>get_option(“sticky_posts”), ‘paged’ => get_query_var(‘paged’), ‘&meta_key=Sortdate&orderby=meta_value&order=asc’) ); ?> With this piece of code, the first condition will be met, and it won’t list posts that are sticky, but the last one […]

paginate_links() Change the order of links

While using paginate_links() function of WordPress, i need to change the order in which it echo’s its output. For example, by default it will output pagination links in this format: Default Output: <<PREV 1 2 3 NEXT>> But i need its output in following format: Required Output: 1 2 3 <<PREV NEXT>> Now, the question […]

Get posts ordered by meta data

I have a post type gtre and metadata price. The ‘price’ metadata I get using get_post_meta($post->ID, ‘key’, true)[“price”]; So I don´t know how exactly should I write the args for WP_Query constructor, so I can get the posts in order by the ‘price‘ meta data. I mean I want the query to ordered by ‘price‘. […]

get_post orderby not working in plugin

Please take a look at the loops below, I’m having issues trying to order the attachment by title, name, and modified. <?php foreach ($instance[‘data’] as $id) : $args = array( ‘include’ => $id, ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘orderby’ => ‘title’, ‘order’ => ‘DESC’, ); $data_attach = get_posts($args); foreach ($data_attach as […]

Create a regular post for every WooCommerce order

I’m trying to make a post, which will list product meta(every order will have only one product) and on that post I want to make visible product variations. So the link will be generated and sent to users mail (I have an idea of sending that email). So whenever the order is created, I need […]

Featured-Content/Featured Posts With Random Order

I am working on dailysuit.de, which features four featured posts at the top, defined by a certain tag. The order is newest to oldest. How do I get this order randomised (and not newest to oldest)? I tried to change something like the following in inc/featured-content.php: // Query for featured posts. $featured = get_posts( array( […]