I am having a problem with my website, I hope you can help me. I created two Custom Post Types(Truck and Stock) and one Custom Taxonomy (Brands). Both post types shares the same taxonomy. I created one post for each post type and assigned the same brand (Isuzu). But when I checked the archive for the Isuzu, only one post shows.

Here are the two dummy posts that filed under taxonomy Brand, Isuzu

http://museph.com/altis/stock/bumblebee/

http://museph.com/altis/truck/isuzu-fb/

How can I fix this? Thanks.

Here are the codes.

For Post Type Truck

add_action('init', 'cpt_register_my_cpt_truck');
function cpt_register_my_cpt_truck() {
register_post_type('truck', array(
'label' => 'Finished Trucks',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'truck', 'with_front' => true),
'query_var' => true,
'has_archive' => true,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),
'labels' => array (
  'name' => 'Finished Trucks',
  'singular_name' => 'Truck',
  'menu_name' => 'Finished Trucks',
  'add_new' => 'Add Truck',
  'add_new_item' => 'Add New Truck',
  'edit' => 'Edit',
  'edit_item' => 'Edit Truck',
  'new_item' => 'New Truck',
  'view' => 'View Truck',
  'view_item' => 'View Truck',
  'search_items' => 'Search Trucks',
  'not_found' => 'No Trucks Found',
  'not_found_in_trash' => 'No Trucks Found in Trash',
  'parent' => 'Parent Truck',
)
)); 
}

For Post Type Stock

add_action('init', 'cpt_register_my_cpt_stock');
function cpt_register_my_cpt_stock() {
register_post_type('stock', array(
'label' => 'Stocks',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'stock', 'with_front' => true),
'query_var' => true,
'exclude_from_search' => true,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),
'labels' => array (
  'name' => 'Stocks',
  'singular_name' => 'Stock',
  'menu_name' => 'Stocks',
  'add_new' => 'Add Stock',
  'add_new_item' => 'Add New Stock',
  'edit' => 'Edit',
  'edit_item' => 'Edit Stock',
  'new_item' => 'New Stock',
  'view' => 'View Stock',
  'view_item' => 'View Stock',
  'search_items' => 'Search Stocks',
  'not_found' => 'No Stocks Found',
  'not_found_in_trash' => 'No Stocks Found in Trash',
  'parent' => 'Parent Stock',
)
) ); }

For Taxonomy Brand

add_action('init', 'cpt_register_my_taxes_brands');
function cpt_register_my_taxes_brands() {
register_taxonomy( 'brands',array (
  0 => 'truck',
  1 => 'stock',
),
array( 'hierarchical' => true,
    'label' => 'Brands',
    'show_ui' => true,
    'query_var' => true,
    'show_admin_column' => true,
    'labels' => array (
  'search_items' => 'Brand',
)
) ); 
}

Read more here: Single taxonomy for multiple post types archive page not working


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , ,

Wordpress related questions and answers: