wordpress add custom post type with categories code example

Example 1: wordpress register post type

function book_setup_post_type() {
    $args = array(
        'public'    => true,
        'label'     => __( 'Books', 'textdomain' ),
        'menu_icon' => 'dashicons-book',
    );
    register_post_type( 'book', $args );
}
add_action( 'init', 'book_setup_post_type' );

Example 2: acf add options page to custom post type

if( function_exists('acf_add_options_page') ) {
    
    acf_add_options_sub_page(array(
        'page_title'     => 'Offers Page Content',
        'menu_title'    => 'offers-page-content',
        'parent_slug'    => 'edit.php?post_type=offers',
    ));

}

Tags:

Php Example