Categorise Custom Post Types

Thanks guys, I found a solution: It’s as easy as adding the post_type_category element to the arguments object within register_post_type(): $args = array( ‘label’ => ‘sausages’, ‘description’ => ‘Sausages’, ‘labels’ => $labels, ‘post_type_category’ => ‘food’, ‘supports’ => array( ‘title’, ‘category’ ), ‘hierarchical’ => false, /* and so on */ ); register_post_type( ‘sausage’, $args ); And … Read more

Why cant I add a custom post type to a custom taxonomy?

The post_category you are using is for core categories taxonomy. For custom taxonomies you have to use tax_input. For example, the next code set terms for custom_tax_category and custom_ta_tag taxonomies. $args = array( ‘post_type’ => ‘custom_post_type’, ‘post_title’ => wp_strip_all_tags( $title ), ‘post_content’ => ‘some content’, ‘post_status’ => ‘publish’, ‘post_author’ => $author_id, ‘tax_input’ => array( ‘custom_tax_category’ … Read more

Showing specific post in order of array wp_query

For anyone struggling with this. ‘orderby’=>’post__in’ makes this work. <?php $successful_musics_array = array(‘1682’, ‘1684’, ‘556’, ‘1793’, ‘558’, ‘1788’, ‘320’, ‘1190’, ‘1865’, ‘1125’, ‘1863’, ‘1540’); $query = new WP_Query( array( ‘post_type’ => ‘songs’, ‘posts_per_page’ => ’15’, ‘post__in’ => $successful_musics_array, ‘orderby’=>’post__in’ ) ); if ( $query->have_posts() ) : ?> <?php while ( $query->have_posts() ) : $query->the_post(); ?> … Read more