<?php
/*
Plugin Name: FAQ plugin
Description: Add faq pages and categories.
Author: LawCarta Team
Text Domain: faq
Version: 0.1
*/

function create_category_type()
{
    // Add a taxonomy like categories
    $labels = array(
        'name'              => 'Categories',
        'singular_name'     => 'Category',
        'search_items'      => 'Search Categories',
        'all_items'         => 'All Categories',
        'parent_item'       => 'Parent Category',
        'parent_item_colon' => 'Parent Category:',
        'edit_item'         => 'Edit Category',
        'update_item'       => 'Update Category',
        'add_new_item'      => 'Add New Category',
        'new_item_name'     => 'New Category Name',
        'menu_name'         => 'Categories',
    );

    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'show_in_admin_bar' => true,
        'query_var'         => true,
        //'rewrite'           => array( 'slug' => 'type' ),
    );

    register_taxonomy('fac_category_type',['fac'],$args);

    // Add a taxonomy like tags
    $labels = array(
        'name'                       => 'Answer',
        'singular_name'              => 'Answer',
        'search_items'               => 'Answers',
        'popular_items'              => 'Popular Answers',
        'all_items'                  => 'All Answers',
        'parent_item'                => 'Category',
        'parent_item_colon'          => 'Category:',
        'edit_item'                  => 'Edit Answer',
        'update_item'                => 'Update Answer',
        'add_new_item'               => 'Add New Answer',
        'new_item_name'              => 'New Answer Name',
        'add_or_remove_items'        => 'Add or remove Answer',
        'menu_name'                  => 'Answers',
    );

    $args = array(
        'hierarchical'          => false,
        'labels'                => $labels,
        'public'                => true,
        'show_ui'               => true,
        'show_in_admin_bar'     => true,
        'taxonomies' => ['fac_category_type'],
        'show_admin_column'     => true,
        'query_var'             => true,
        'publicly_queryable'    => true,
        'rewrite'               => array( 'slug' => 'faq/answer' ),
    );

    register_post_type( 'fac_category_answer', $args );

}

add_action('init','create_category_type');