Custom Admin Menu Order

The actual slug for the WooCommerce menu item is ‘woocommerce’. So if you replace: ‘edit.php?post_type=shop_order’, // WooCommerce with: ‘woocommerce’, // WooCommerce the above code will work. I found a handy function that will display all the items in the menu array at How to remove admin menu pages inserted by plugins?. Here is the function … Read more

Sorting posts by custom fields in meta_query

As of WordPress 4.2, you can combine meta_query and orderby. The following example is taken from make.wordpress.org. Example of a simple meta_query: $q = new WP_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘state_clause’ => array( ‘key’ => ‘state’, ‘value’ => ‘Wisconsin’, ), ‘city_clause’ => array( ‘key’ => ‘city’, ‘compare’ => ‘EXISTS’, ), ), ‘orderby’ … Read more

Query random post from different categories

Random ordering is quite expensive operations in SQL and can become a headache on very big sites. Getting a random post from a category for 6 categories will mean you might need to run 6 separate queries, each ordered randomly. This can really break the bank and leave you bankrupt. From your answer and looking … Read more

Wp query orderby ‘title’ doesn’t work

Try adding ‘suppress_filters’ => true to your query args. Maybe you have a plugin that modifies the queries. You could also check if the posts out of order (the first one) is a sticky post. Sticky posts by default skip the order queue. You can disable this by adding ‘ignore_sticky_posts’ => true to your query … Read more

How do I get the latest note on the order at woocommerce? [closed]

The order notes are saved as post comments, so you can use the WordPress function get_comments() to get the last note: $args = array( ‘post_id’ => $order_id, ‘orderby’ => ‘comment_ID’, ‘order’ => ‘DESC’, ‘approve’ => ‘approve’, ‘type’ => ‘order_note’, ‘number’ => 1 ); remove_filter( ‘comments_clauses’, array( ‘WC_Comments’, ‘exclude_order_comments’ ), 10, 1 ); $notes = get_comments( … Read more

Sort wp_nav_menu() by menu order

The nav_menu_items are already sorted by menu_order. When you go into the Appearance -> Menus and arrange the order menu the menu_order of each menu item gets updated. To change the orderby parameter in the query that displays the menu you can use pre_get_posts to alter it. Example: add_action( ‘pre_get_posts’, ‘wpse_sort_nav’ ); function wpse_sort_nav( $query … Read more

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