All, published and pending order

Filter views_edit-post. function tst($a) { // var_dump(get_defined_vars()); $tst = array(); $tst[‘future’] = $a[‘future’]; $tst[‘publish’] = $a[‘publish’]; $tst[‘all’] = $a[‘all’]; return $tst; } add_filter(‘views_edit-post’,’tst’); You can juggle that new array however you want. The only keys that are present in the incoming array are the one that have posts so you should check that the key … Read more

Order posts by price

You are storing your “price” (apparently) as human readable formatted currency. That makes it a string. And that means it is going to be sorted alphabetically, more or less, and not numerically as you need it to be. If you can store those values without the punctuation, and use meta_value_num— your second query above (but … Read more

Allow user to set custom order to a list of custom taxonomies?

For those interested I figured it out. I added this to my functions.php: function set_the_terms_in_order ( $terms, $id, $taxonomy ) { $terms = wp_cache_get( $id, “{$taxonomy}_relationships_sorted” ); if ( false === $terms ) { $terms = wp_get_object_terms( $id, $taxonomy, array( ‘orderby’ => ‘term_order’ ) ); wp_cache_add($id, $terms, $taxonomy . ‘_relationships_sorted’); } return $terms; } add_filter( … Read more

WP_Query orderby not working with meta_value_num and menu_order

Found an answer to this. Somehow WordPress’ own orderby isn’t fully functional when trying to order by multiple values. I solved this by changing WP_Query to SQL Query, and including second DESC after _postmeta.meta_value+0 SELECT XXX_posts.* FROM XXX_posts INNER JOIN XXX_postmeta ON (XXX_posts.ID = XXX_postmeta.post_id) WHERE 1=1 AND XXX_posts.post_type=”sidebar_element” AND (XXX_posts.post_status=”publish”) AND (XXX_postmeta.meta_key = ‘sidebar_element_meta_alignment’ … Read more

Wp_query: sort by PHP variable

To the best of my knowledge, you cannot sort a query by two different parameters without an additional iteration over the retrieved posts. Since that ideally should be avoided, let me suggest a different approach: How about incorporating an additional meta value “sort_date”, or the like? And then, in your saving routine, save either the … Read more

Show first the posts from 1 specific tag

You can use meta key for ordering your result. See reference from codex here. Ex. $args = array( ‘post_type’ => ‘post’, ‘meta_key’ => ‘priority’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); $query = new WP_Query($args);

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