Skip to content

Instantly share code, notes, and snippets.

@paaljoachim
Last active September 10, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paaljoachim/1458a46011ec5e6ca2f93954d5f2745e to your computer and use it in GitHub Desktop.
Save paaljoachim/1458a46011ec5e6ca2f93954d5f2745e to your computer and use it in GitHub Desktop.
Using the CPT - Custom Post Type UI plugin to create Custom Post Types
function cptui_register_my_cpts() {
/**
* Post Type: Nettmagasin.
*/
$labels = array(
"name" => __( "Nettmagasin", "tm-beans" ),
"singular_name" => __( "Nettmagasin", "tm-beans" ),
"all_items" => __( "Alle Nettmag tekster", "tm-beans" ),
"archives" => __( "Nettmagasin arkiv", "tm-beans" ),
);
$args = array(
"label" => __( "Nettmagasin", "tm-beans" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => true,
"rest_base" => "",
"has_archive" => "nettmagasin-arkiv",
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => true,
"rewrite" => array( "slug" => "nettmagasin", "with_front" => true ),
"query_var" => true,
"menu_position" => 5,
"menu_icon" => "dashicons-calendar-alt",
"supports" => array( "title", "editor", "thumbnail", "excerpt", "custom-fields", "comments", "revisions", "author" ),
"taxonomies" => array( "nettmagasin_kategorier", "nettmagasin_stikkord" ),
);
register_post_type( "nettmagasin", $args );
/**
* Post Type: Edwien.
*/
$labels = array(
"name" => __( "Edwien", "tm-beans" ),
"singular_name" => __( "Edwien", "tm-beans" ),
"menu_name" => __( "Edwien", "tm-beans" ),
"all_items" => __( "Alle Edwiens tekster", "tm-beans" ),
"archives" => __( "Edwiens arkiv", "tm-beans" ),
);
$args = array(
"label" => __( "Edwien", "tm-beans" ),
"labels" => $labels,
"description" => "Edwiens Tekster",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => true,
"rest_base" => "",
"has_archive" => "edwiens-arkiv",
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => true,
"rewrite" => array( "slug" => "edwien", "with_front" => true ),
"query_var" => true,
"menu_position" => 5,
"menu_icon" => "dashicons-admin-users",
"supports" => array( "title", "editor", "thumbnail", "excerpt", "author" ),
"taxonomies" => array( "edwien_kategori", "edwien_stikkord" ),
);
register_post_type( "edwien", $args );
}
add_action( 'init', 'cptui_register_my_cpts' );
@paaljoachim
Copy link
Author

Post meta is not showing up on the custom archive or single custom post pages.

screen shot 2018-09-10 at 17 52 23

and

screen shot 2018-09-10 at 17 53 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment