Custom Content Types
-
Hi I am trying to create several new content types in one fell swoop. However, it seems I am having some issues when I try to create more than one custom post type.
Below I have created an array with shared arguments for register_post_type()… I then have the arguments unique to each post type such as ‘label’, ‘singular’ and ‘query_var’, then call the register_post_type() with the appropriate content type name…
When I have both at the same time, they show up but the Admin page says ‘No Posts to display’ instead of a table with the posts, even though it says there are posts. When I comment out the second register_post_type() function however the single post type will display that table… Am I doing something wrong? How can I declare multiple, similar content types as easily as possible?
`add_action(“init”, “price_Init”);
function price_Init()
{
$arguments= array();
$arguments[‘public’] = true;
$arguments[‘show_ui’] = true;
$arguments[‘_builtin’] = false;
$arguments[‘_edit_link’] = ‘post.php?post=%d’;
$arguments[‘capability_type’] = ‘post’;
$arguments[‘hierarchical’] = false;
$arguments[‘supports’] = array(‘title’,’author’, ‘excerpt’, ‘editor’);$arguments[‘rewrite’] = array(“slug” => ‘alert’);
$arguments[‘query_var’] = ‘alert’;
$arguments[‘label’] = __(‘Alerts’);
$arguments[‘singular_label’] = __(‘Alert’);
register_post_type(‘alerts’, $arguments);$arguments[‘rewrite’] = array(“slug” => ‘order’);
$arguments[‘query_var’] = ‘order’;
$arguments[‘label’] = __(‘Orders’);
$arguments[‘singular_label’] = __(‘Order’);
//register_post_type(‘orders’, $arguments);}
- The topic ‘Custom Content Types’ is closed to new replies.