Register an FAQ Post Type
Registers an FAQ custom post type with REST API support so FAQ entries can be managed in the admin and queried via the block editor.
PHPby SnipCraft
php
<?php
add_action( 'init', 'scseed_register_faq_cpt' );
if ( ! function_exists( 'scseed_register_faq_cpt' ) ) {
function scseed_register_faq_cpt() {
$labels = array(
'name' => 'FAQs',
'singular_name' => 'FAQ',
'add_new_item' => 'Add New FAQ',
'edit_item' => 'Edit FAQ',
'new_item' => 'New FAQ',
'view_item' => 'View FAQ',
'search_items' => 'Search FAQs',
'not_found' => 'No FAQs found',
'not_found_in_trash' => 'No FAQs found in trash',
'menu_name' => 'FAQs',
);
register_post_type( 'faq', array(
'labels' => $labels,
'public' => true,
'has_archive' => false,
'rewrite' => array( 'slug' => 'faq' ),
'supports' => array( 'title', 'editor' ),
'show_in_rest' => true,
'menu_icon' => 'dashicons-editor-help',
) );
}
}#content#cpt#faq#register-post-type