Skip to content

Instantly share code, notes, and snippets.

@flexseth
Created July 16, 2019 21:14
Show Gist options
  • Save flexseth/d45724e4eac96bf15b83d7369cdef40b to your computer and use it in GitHub Desktop.
Save flexseth/d45724e4eac96bf15b83d7369cdef40b to your computer and use it in GitHub Desktop.
Todo Custom Post Type for Project Management (PM) on WordPress
<?php
function fp_register_my_cpts_todo() {
/**
* Post Type: Todos.
*/
$labels = array(
"name" => __( "Todos", "american-idea-foundation" ),
"singular_name" => __( "Todo", "american-idea-foundation" ),
);
$args = array(
"label" => __( "Todos", "american-idea-foundation" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => array( "slug" => "todo", "with_front" => true ),
"query_var" => true,
"menu_icon" => "dashicons-hammer",
"supports" => array( "title", "editor", "thumbnail" ),
"taxonomies" => array( "category", "post_tag" ),
);
register_post_type( "todo", $args );
}
add_action( 'init', 'fp_register_my_cpts_todo' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment