Post Type Generator

Overview

Use this tool to create custom code for Post Types with register_post_type() function.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

The function used in the code.
Add Child Themes Support.
Translation file Text Domain. Optional.
Key used in the code. Up to 20 characters, lowercase, no spaces.
A short descriptive summary of the post type.
Post type singular name. e.g. Product, Event or Movie.
Post type plural name. e.g. Products, Events or Movies.
Comma separated list of Taxonomies.
Hierarchical post types allows descendants.
Enables post type export.
Enables post type archives. Post type key is used as defauly archive slug.
Set custom archive slug.
Show post type in the admin UI.
Show post type UI in the admin.
Show post type in admin sidebar.
Show post type in admin bar.
Show post type in Navigation Menus.
Direct query variable used in WP_Query. e.g. WP_Query( array( 'post_type' => 'product', 'term' => 'disk' ) )
Enable front end queries as part of parse_request().
Custom query variable.
Set user capabilities to manage post type.
Used as a base to construct capabilities.
Whether to add the post type route in the REST API 'wp/v2' namespace.
To change the base url of REST API route. Default is the post type key.
REST API Controller class name. Default is 'WP_REST_Posts_Controller'.
  Save Snippet
if ( ! function_exists('areas_post_type') ) {

// Register Custom Post Type
function areas_post_type() {

	$labels = array(
		'name'                  => _x( 'Áreas de Atuação', 'Post Type General Name', 'nw2' ),
		'singular_name'         => _x( 'Área de Atuação', 'Post Type Singular Name', 'nw2' ),
		'menu_name'             => __( 'Áreas de Atuação', 'nw2' ),
		'name_admin_bar'        => __( 'Áreas de Atuação', 'nw2' ),
		'archives'              => __( 'Arquivo de Áreas de atuação', 'nw2' ),
		'attributes'            => __( 'Item Attributes', 'nw2' ),
		'parent_item_colon'     => __( 'Áreas Relacionadas', 'nw2' ),
		'all_items'             => __( 'Todas as Áreas', 'nw2' ),
		'add_new_item'          => __( 'Adicionar Área', 'nw2' ),
		'add_new'               => __( 'Adicionar Área', 'nw2' ),
		'new_item'              => __( 'Nova área', 'nw2' ),
		'edit_item'             => __( 'Editar área', 'nw2' ),
		'update_item'           => __( 'Atualizar área', 'nw2' ),
		'view_item'             => __( 'Ver área', 'nw2' ),
		'view_items'            => __( 'View Items', 'nw2' ),
		'search_items'          => __( 'Procurar área', 'nw2' ),
		'not_found'             => __( 'Nenhuma área encontrada', 'nw2' ),
		'not_found_in_trash'    => __( 'Nada encontrado na lixeira', 'nw2' ),
		'featured_image'        => __( 'Imagem destacada', 'nw2' ),
		'set_featured_image'    => __( 'Definir imagem destacaad', 'nw2' ),
		'remove_featured_image' => __( 'Remover imagem destacada', 'nw2' ),
		'use_featured_image'    => __( 'Usar como imagem destacada', 'nw2' ),
		'insert_into_item'      => __( 'Inserir dentro da área', 'nw2' ),
		'uploaded_to_this_item' => __( 'Fazer upload para este item', 'nw2' ),
		'items_list'            => __( 'Lista de parea', 'nw2' ),
		'items_list_navigation' => __( 'Navegação da lista de áras', 'nw2' ),
		'filter_items_list'     => __( 'Filtrar áreas', 'nw2' ),
	);
	$rewrite = array(
		'slug'                  => 'areas-de-atuacao-em-direito',
		'with_front'            => true,
		'pages'                 => true,
		'feeds'                 => true,
	);
	$args = array(
		'label'                 => __( 'Área de Atuação', 'nw2' ),
		'description'           => __( 'Cadastro de Áreas de Atuação', 'nw2' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'post-formats' ),
		'hierarchical'          => true,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 5,
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'rewrite'               => $rewrite,
		'capability_type'       => 'post',
	);
	register_post_type( 'areas', $args );

}
add_action( 'init', 'areas_post_type', 0 );

}