How to order posts by meta_value created inside loop?

In your WP_Query, only return ids. https://developer.wordpress.org/reference/classes/wp_query/#return-fields-parameter Create an empty array, $myArray = array();. Then loop thru the results of the query, $your_query->posts and fetch your field value for each id and add the result and the id to a new array in $myArray. Then sort the arrays in $myArray by the price. Then do … Read more

Combining sorted and random CPT

Try to get two different arrays of posts and loop through array A. Before get post data of A element get random element from array B. For example: $array_a = [‘post_id_a1’, ‘post_id_a2’, ‘post_id_a3’]; $array_b = [‘post_id_b1’, ‘post_id_b2’, ‘post_id_b3’]; foreach ( $array_a as $a_post_id ) { $is_b_should_displayed = mt_rand( 0, 1 ); if ( $is_b_should_displayed && … Read more

WordPress query_posts and orderby page order

I was going to suggest using &orderby=menu_order, but you already pointed it out in your comment. 🙂 p.s. you can answer your own question, I think. Since you found the answer to your question, just post your own answer. I think it”s kosher to accept your own answer?

Order query by post meta value

Take a look at the WordPress Codex: http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby function edit_posts_orderby($orderby_statement) { $orderby_statement = “meta_value DESC”; return $orderby_statement; } add_filter(‘posts_orderby’, ‘edit_posts_orderby’); If you’re making the WP_Query yourself you can change the orderby parameter to meta_value Take a look here: http://codex.wordpress.org/Class_Reference/WP_Query

Arrange posts by date in front page

Add orderby and order to your arguments: $cat_query = new WP_Query( array( ‘post__not_in’ => get_option( ‘sticky_posts’ ), ‘category__in’ => array($cat->term_id), ‘posts_per_page’ => 5, ‘paged’ => $paged, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) ); Update it seems it still takes one category, lists 5 posts and then goes to another, with 5 posts etc. It … Read more

Custom order categories in admin dashboard

Use the get_terms_args hook and modify the orderby argument, like so: add_filter( ‘get_terms_args’, ‘my_sort_terms’, 10, 2 ); function my_sort_terms( $args, $taxonomies ) { $args[‘orderby’] = ‘description’; return $args; } Possible values for this argument are listed in the codex.

orderby:date not working

You should not have to specify orderby=date. That is the default. If you look at the query, you will see that the field used is post_date, which is the publication date and not the modification date– post_modified. You can prove this just by dumping $wp_query after your call to query_posts. Or try: $q = new … Read more

How do I make a custom taxonomy for a CPT appear inbetween title and editor boxes?

In your case you can edit the following code to accomplish what you are looking for by assigning the custom taxonomy meta box to a custom context and then running do_meta_boxes /** * insert meta boxes before main editor below title */ function wpse_140900_add_meta_boxes_after_title( $post ){ // per the comment below filter by post type … Read more

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