Custom Admin Post Column change order

Thanks to @cameronjonesweb’s link, here’s the code you might use: add_filter( ‘manage_edit-post_sortable_columns’, ‘my_add_sortable_custom_column’); function my_add_sortable_custom_column( $columns ) { $columns[‘views’] = ‘views’; return $columns; } add_action( ‘pre_get_posts’, ‘my_sort_custom_column’ ); function my_sort_custom_column( $query ) { if( ! is_admin() || ! $query->is_main_query() ) { return; } if ( ‘views’ === $query->get( ‘orderby’) ) { $query->set( ‘orderby’, ‘meta_value’ ); … Read more

How to orderby Taxonomy Term in a WP Query

You can’t order by taxonomy terms, the very concept breaks down when you try to handle posts that have multiple terms in a taxonomy. You may know that only 1 term will ever be selected but WP_Query isn’t built that way. Instead, keep your taxonomy so that you retain all the performance/theming/Admin UI benefits, but … Read more

Change Menu Order

If it’s greyed out it’s because you haven’t created a menu yet. Once you give it a name and save it, you should be able to add pages and links to your menu. Once you have links/pages, you can begin to sort the menu by dragging them up or down.

Sort wordpress posts by facebook likes [closed]

You can either sort them with jQuery on the front-end, or pull the like count into the back-end and store on the post_meta. Then sort by meta value in your loop. FACEBOOK http://graph.facebook.com/?id=http://{URL} Result { “id”: “http://{URL}”, “shares”: intgr/(number) } Other types of share counts.

WordPress Not Sorting By Custom Field

Please read the documentation. ‘rating’ is not a valid value for orderby. To sort by a custom field you need to use ‘orderby’ => ‘meta_value’ or ‘meta_value_num’. Note that a ‘meta_key=keyname‘ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can … Read more

Orderby with menu_order and title

MySQL does not do “natural” sorting natively, though there are attempts to make it work. I have no idea how that plugin you mention works but sorting by menu_order with a post_title fallback is trivial. add_action( ‘pre_get_posts’, function ($qry) { if ($qry->is_main_query()) { $qry->set(‘orderby’,’menu_order title’); } } ); Of course, that gets menu_order equal 0 … Read more

How to search for articles containing two words?

Ex. http://www.site.com/?s=as+sa This gives a perfect search result irrespective of the order of words. If you want to add a custom query then you can use following: $query = new WP_Query( ‘s=keyword+keyword2’ ); and iterate through your query result. Try this out.