How to Add Categories to a Custom Post Type in WordPress

To display your custom post types on the same category page as your default posts, you need to add this code into your theme’s functions.php or a site-specific plugin. add_filter(‘pre_get_posts’, ‘query_post_type’); function query_post_type($query) {   if( is_category() ) {     $post_type = get_query_var(‘post_type’);     if($post_type)         $post_type = $post_type;     else         $post_type = array(‘nav_menu_item’, ‘post’, ‘movies’); // don’t forget nav_menu_item … Read more

Quick Tip: Hierarchical Custom Post Types Not Working for You?

A hierarchical post type is a post type with a parent and one or more children. The pages post type in WordPress is a classic example of a hierarchical post type. One page can be the parent of other pages, that can be parents of other pages in a hierarchical fashion. register_post_type() function is how … Read more

How to Display Custom Post Type Category (With Name & Link!)

Get Category of a Custom Post Type To get categories of a custom post type and display them along with their respective posts, I will use the the_terms() function inside the loop. the_terms() function display all the associated categories of a custom post type. It requires two parameters, post_id and taxonomy slug.

Require Post Title for Custom Post Type

By default, if a user leaves the title field blank, WordPress will still allow the post to be published or updated. What we want to do is prevent the custom post type from being published/updated until it has a valid title, and let the user know they need to enter one.