0

I've registered several custom post type using a custom plugin. All of them seems to work fine. All are listed under the Post Menu.

The problem occurs when I saved a custom post entry. The custom post type is saved on the database, and the permalink works fine from the front end. But strangely, the custom post type table is empty. The post status filter, shows ' All (1) | Published (1) '. Screenshot

After some investigation, I found out that this happens after the second register_post_type() is called in my custom plugin.

How can i fix this problem?

Thank you.

Added

Here is 2 of the register_post_type code. Each of them are called from a different file using include_once ('product/product.php'); and include_once ('order/order.php');

add_action('init', 'product_post_type', 0 );

function product_post_type() {

$product_labels = array(
    'name' => _x('Product', 'post type general name'),
    'singular_name' => _x('Product', 'post type singular name'),
    'add_new' => _x('Add New', 'investment'),
    'add_new_item' => __('Add New Product'),
    'edit_item' => __('Edit Product'),
    'new_item' => __('New Product'),
    'view_item' => __('View Product'),
    'search_items' => __('Search Product'),
    'not_found' =>  __('No product found'),
    'not_found_in_trash' => __('No product found in Trash'), 
    'parent_item_colon' => '',
    'menu_name' => 'Product'
);
$product_args = array(
    'labels' => $product_labels,
    'public' => true,
    'can_export' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'product' ),
    'capability_type' => 'post',
    'map_meta_cap' => true,
    'has_archive' => true, 
    'hierarchical' => true,
    'menu_position' => 6,
    'show_in_nav_menus' => false,
    'supports' => array('title','editor','thumbnail','comments')
); 

register_post_type('product',$product_args);

}


add_action('init', 'order_post_type', 0 );

function order_post_type() {

$order_labels = array(
    'name' => _x('Order', 'post type general name'),
    'singular_name' => _x('Order', 'post type singular name'),
    'add_new' => _x('Add New', 'investment'),
    'add_new_item' => __('Add New Order'),
    'edit_item' => __('Edit Order'),
    'new_item' => __('New Order'),
    'view_item' => __('View Order'),
    'search_items' => __('Search Order'),
    'not_found' =>  __('No order found'),
    'not_found_in_trash' => __('No order found in Trash'), 
    'parent_item_colon' => '',
    'menu_name' => 'Order'
);
$order_args = array(
    'labels' => $order_labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => true,
    'menu_position' => 8,
    'supports' => array('title')


); 

register_post_type('order',$order_args);

}
2
  • show us the code you are using to register your custom post types
    – Milo
    Commented Oct 17, 2012 at 4:12
  • done that @Milo
    – ifdion
    Commented Oct 17, 2012 at 4:28

1 Answer 1

0

Some words used as names for post types will produce unpredictable results, in your case, the word order is a reserved term and is causing problems with the query. Change that post type name to something unique and the admin UI will behave.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.