Order by empty custom field

There are two solutions for that: 1. Make sure that all posts have that field set. You can do this easily – just use save_post hook and set it to default value. (You should also add default values for already existing posts that don’t have that field set.) 2. Use a little bit modified query … Read more

I Changed the Menu Order, But the Page Order Didn’t Change on Front Page

By default, posts and pages are sorted after the date. If you want sort pages by “order” field, which is visible on edit page, you have to set orderby parameter: add_action(‘pre_get_posts’, ‘change_order’); function change_order($query) { if ( is_front_page() || is_home() ) { $query->set( ‘orderby’, ‘menu_order’ ); $query->set( ‘order’, ‘ASC’ ); } return $query; } Put … Read more

Order by summing multiple values

I wouldn’t use taxonomies or custom fields for this purpose. Every time you’re add one custom field for a query, you have to add a JOIN part for that query – it means that with 10-15 custom fields, you’ll get query with 10-15 joins – so such query will be very slow. But there is … Read more

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