I am facing an issue. I’m new in wordpress. I created a function for custom post types. This is my code.
function my_cpt(){
$labels = array(
'name' => 'SM & Points Templates',
'add_new' => 'Add New SM & Points Template(s)',
'add_new_item' => 'Add New SM & Points Template(s)',
'edit_item' => 'Edit SM & Points Template(s)'
);
$args = array(
'labels' => $labels,
'menu_icon' => 'dashicons-arrow-right-alt',
'public' => true,
'supports' => array('title')
);
register_post_type('custom_settings', $args);
$labels1 = array(
'name' => 'Fine Print',
'add_new' => 'Add New Fine Print',
'add_new_item' => 'Add New Fine Print',
'edit_item' => 'Edit Fine Print'
);
$args1 = array(
'labels' => $labels1,
'menu_icon' => 'dashicons-arrow-right-alt',
'public' => true,
'supports' => array('title')
);
register_post_type('fine_prints', $args1);
$labels2 = array(
'name' => 'Post Hints',
'add_new' => 'Add New Post Hint',
'add_new_item' => 'Add New Post Hint',
'edit_item' => 'Edit Post Hint'
);
$args2 = array(
'labels' => $labels2,
'menu_icon' => 'dashicons-arrow-right-alt',
'public' => true,
'supports' => array('editor')
);
register_post_type('post_hints', $args2);
$labels3 = array(
'name' => 'States',
'add_new' => 'Add New State',
'add_new_item' => 'Add New State',
'edit_item' => 'Edit State'
);
$args3 = array(
'labels' => $labels3,
'menu_icon' => 'dashicons-arrow-right-alt',
'public' => true,
'supports' => array('title')
);
register_post_type('states', $args3);
$labels4 = array(
'name' => 'Help',
'add_new' => 'Add Help',
'add_new_item' => 'Add Help',
'edit_item' => 'Edit Help'
);
$args4 = array(
'labels' => $labels4,
'menu_icon' => 'dashicons-arrow-right-alt',
'public' => true,
'supports' => array('title')
);
register_post_type('helps', $args4);
}
add_action('init', 'my_cpt');
The issue is that First 4 posts are appearing in admin menu. But last Helps
is not appearing in menu bar. Where am I wrong? Please see the this image.
After States
, there should be Help
.
EDIT:
When I was adding the last custom post, I made a small mistake. I added this code.
$labels4 = array(
'name' => 'Help',
'add_new' => 'Add Help',
'add_new_item' => 'Add Help',
'edit_item' => 'Edit Help'
);
$args4 = array(
'labels' => $labels4,
'menu_icon' => 'dashicons-arrow-right-alt',
'public' => true,
'supports' => array('title')
);
register_post_type('states', $args4);
Now the last two custom post types had same id states
. But when I saw it, I changed it to helps
. It was appearing when I added it for the first time with states
id. But when I changed it to helps
, It disappeared. In the top menu, Helps
is visible under New but not in admin menu.
Well, the final menu must appear because the code is right..Try to make the last menu in a separate function and hook..maybe it appears like:
I found the issue. There was a conflict with plugin WooCommerce Deals. When I deactivated it, the issue was resolved.