Post order by selected tags
You can count the number of tags when a post is saved and store it as a meta key for the post. Now you can just add a sort by the value of the meta key to the tag page query.
You can count the number of tags when a post is saved and store it as a meta key for the post. Now you can just add a sort by the value of the meta key to the tag page query.
orderby in WP_query doesn’t works
Using has_term() requires the name of the taxonomy as a parameter. References: has_term() does not return when term is assigned post? Function Reference/has term
tl;dr; This is not possible with tax_query. A tax_query is a restriction of the results delivered, not used to order posts. You use the Order & Orderby Parameters for that. A little excursion into statistics This has to do with statistics and mathematics, as a taxonomy is a nominal scale, meaning it is just a … Read more
I don’t understand why can’t you use the post_date of the custom post type which includes date and time together? $arg = array( ‘post_type’ => ‘custom_post_type’, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’) $result = get_posts($args);
Order a query by meta_value and then by post_date
As far as I know, you can’t actually publish a post without a title. WP might erroneously say your posts are published, but I’m pretty sure they’re still viewed as drafts, which is why you don’t get any post results. First, make sure your custom post type supports your custom field: $args = array( ‘post_type’ … Read more
The parameter should be orderby rather than order_by. (See codex)
If you use a filter like the following to adjust the order of a post type archive, then the next & previous links will work perfectly without need for modification: function wpse_139866_set_order_by( $wp_query ) { if ( ! is_admin() && $wp_query->is_post_type_archive( ‘my_post_type’ ) && $wp_query->is_main_query() ) { $wp_query->set( ‘orderby’, ‘title’ ); } } add_action( ‘pre_get_posts’, … Read more
query_posts with sorting on a custom datestamp