get all category custom post type wordpress dev

  1. In your WordPress theme, open the functions.php file.
  2. Add the following code to register the custom post type:
function create_custom_post_type() {
  register_post_type( 'custom_post_type_name',
    array(
      'labels' => array(
        'name' => __( 'Custom Post Types' ),
        'singular_name' => __( 'Custom Post Type' )
      ),
      'public' => true,
      'has_archive' => true,
    )
  );
}
add_action( 'init', 'create_custom_post_type' );
  1. After adding the code, save the file.

  2. Create a new file in your theme directory and name it custom-post-type-template.php.

  3. Add the following code to display the custom post type:
<?php
$args = array( 'post_type' => 'custom_post_type_name', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
  the_title();
  echo '<div class="entry-content">';
  the_content();
  echo '</div>';
endwhile;
?>
  1. Save the file.

  2. In your WordPress admin panel, navigate to Posts > Categories and create the desired categories for the custom post type.

  3. When creating or editing a custom post, assign the appropriate category to it.

  4. After completing these steps, you will have successfully set up a custom post type with categories in WordPress.