Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save encoderit-arman/caf2e71fac0a3aa6612ef02998c6de61 to your computer and use it in GitHub Desktop.
Save encoderit-arman/caf2e71fac0a3aa6612ef02998c6de61 to your computer and use it in GitHub Desktop.
$post_types = [
'faqs' => [
'post_slug' => 'faqs',
'post_title' => 'Faqs',
'taxonomy_name' => 'faqs-category',
'dashicons' => 'dashicons-admin-site-alt3',
'taxonomy' => false,
'thumbnail' => false
],
];
// var_dump($post_types);
foreach ($post_types as $k => $v) {
$supports = ['title', 'editor'];
if ($v['taxonomy']) {
$taxonomy = $v['taxonomy_name'];
} else {
$taxonomy = '';
}
register_post_type(
$k,
array(
'labels' => array(
'name' => __($v['post_title']),
'singular_name' => __($v['post_title']),
'add_new' => __('Add New'),
'add_new_item' => __('Add New ' . $v['post_title']),
'edit_item' => __('Edit ' . $v['post_title']),
'new_item' => __('New ' . $v['post_title']),
'featured_image' => __($v['post_title'] . ' Image', 'textdomain'),
'view_item' => __('View ' . $v['post_title']),
'not_found' => __('Sorry, we couldn\'t find the ' . $v['post_title'] . ' you are looking for.')
),
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'menu_position' => 6,
'has_archive' => true,
'hierarchical' => false,
'menu_icon' => $v['dashicons'],
'taxonomies' => array($taxonomy),
'capability_type' => 'page',
'rewrite' => array('slug' => $v['post_slug']),
'supports' => $supports
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment