How to show related posts of category on post within custom posttype

@ricardio-de-penning I think you are going on wrong direction. You just want to get only those posts which is related to current category right? If yes then you need to filter post using tax_query like below. $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, ‘terms’ => array($cat_ids), … Read more

Order custom post type by taxonomy

Add Meta key value: function my_pre_get_posts( $query ) { // do not modify queries in the admin if( is_admin() ) { return $query; } // only modify queries for ‘model’ post type if ( $query->is_tax( ‘model-year’ ) && $query->is_main_query() ) { $query->set(‘orderby’, ‘meta_value’); // Add Metakey ( “Custome field name” ); $query->set(‘meta_key’, ‘order_number’); $query->set(‘order’, ‘ASC’); … Read more