1

I'm hoping one of you WP gurus can spot what I am missing. I have a CPT that won't register for some reason. It' virtually identical to another CPT that is registered just fine.

I have a custom post type for cartoon-series with a special-features cpt to go with it. Then I have a movies cpt with movie-special-features. The first three work. movie-special-features does not. I literally cut-and-pasted the special-features code and change the areas that needed to be unique. It just fails to load in the back-end. I use the same rewrite code for both. Again, special-features works fine. If I use rewrite analyzer on movie-special-features, the analyzer output shows the correct rewrite rule being used, but it is red and crossed-out and says "This query variable is not public and will not be saved" when I hover the mouse over it.

At first I thought it was a rewrite problem, but if I get rid of all rewrite rules pertaining to these two cpts, special-features still works on the back-end (although obviously the path for the post would be wrong), and movie-special-features does not.

Can any of you see something wrong with my cpt code?

Here is my code:

// -----------------------------------------------------
// Cartoon Series - cartoon-series
// -----------------------------------------------------
    $labels = array(
        "name" => "Cartoon Series",
        "singular_name" => "Cartoon Series",
        "menu_name" => "Cartoon Series",
        "all_items" => "All Cartoon Series",
        "add_new" => "Add New",
        "add_new_item" => "Add New Cartoon Series",
        "edit" => "Edit",
        "edit_item" => "Edit Cartoon Series",
        "new_item" => "New Cartoon Series",
        "view" => "View",
        "view_item" => "View Cartoon Series",
        "search_items" => "Search Cartoon Series",
        "not_found" => "No Cartoon Series Found",
        "not_found_in_trash" => "No Cartoon Series Found in Trash",
        "parent" => "Parent Cartoon Series",
        );

$args = array(
    "labels" => $labels,
    "description" => "",
    "public" => true,
    "show_ui" => true,
    "has_archive" => true,
    "show_in_menu" => true,
    "exclude_from_search" => false,
    "capability_type" => "post",
    "map_meta_cap" => true,
    "hierarchical" => true,
    "rewrite" => array( "slug" => "cartoon-series", "with_front" => true ),
    "query_var" => true,
    "supports" => array( "title", "revisions" )
    );
register_post_type( "cartoon-series", $args );


//==================================================================================
// -----------------------------------------------------
// Special Features - special-features
// -----------------------------------------------------
    $labels = array(
        "name" => "Special Features",
        "singular_name" => "Special Feature",
        "menu_name" => "Special Features",
        "all_items" => "All Special Features",
        "add_new" => "Add New",
        "add_new_item" => "Add New Special Feature",
        "edit" => "Edit",
        "edit_item" => "Edit Special Feature",
        "new_item" => "New Special Feature",
        "view" => "View",
        "view_item" => "View Special Feature",
        "search_items" => "Search Special Features",
        "not_found" => "No Special Features Found",
        "not_found_in_trash" => "No Special Features Found in Trash",
        "parent" => "Parent Special Feature",
        );

    $args = array(
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "show_ui" => true,
        "has_archive" => true,
        "show_in_menu" => true,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => false,
        "rewrite" => array( "slug" => "cartoon-series/%series_name%", "with_front" => true ),
        "query_var" => true,
        "supports" => array( "title", "revisions" ),
        );
    register_post_type( "special-features", $args );

//==================================================================================
// -----------------------------------------------------
// Movies - movies
// -----------------------------------------------------
    $labels = array(
        "name" => "Movies",
        "singular_name" => "Movie",
        "menu_name" => "Movies",
        "all_items" => "All Movies",
        "add_new" => "Add New",
        "add_new_item" => "Add New Movie",
        "edit" => "Edit",
        "edit_item" => "Edit Movie",
        "new_item" => "New Movie",
        "view" => "View",
        "view_item" => "View Movie",
        "search_items" => "Search Movies",
        "not_found" => "NO Movies Found",
        "not_found_in_trash" => "No Movies Found in Trash",
        "parent" => "Parent Movie"
        );

    $args = array(
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "show_ui" => true,
        "has_archive" => true,
        "show_in_menu" => true,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => false,
        "rewrite" => array( "slug" => "movies", "with_front" => true ),
        "query_var" => true,
        "supports" => array( "title", "revisions" )
        );
    register_post_type( "movies", $args );

//==================================================================================
// -----------------------------------------------------
// Movie Special Features - movie-special-features
// -----------------------------------------------------
    $labels = array(
        "name" => "Movie Special Features",
        "singular_name" => "Movie Special Feature",
        "menu_name" => "Movie Special Features",
        "all_items" => "All Movie Special Features",
        "add_new" => "Add New",
        "add_new_item" => "Add New Movie Special Feature",
        "edit" => "Edit",
        "edit_item" => "Edit Movie Special Feature",
        "new_item" => "New Movie Special Feature",
        "view" => "View",
        "view_item" => "View Movie Special Feature",
        "search_items" => "Search Movie Special Features",
        "not_found" => "No Movie Special Features Found",
        "not_found_in_trash" => "No Movie Special Features Found in Trash",
        "parent" => "Parent Movie Special Feature",
        );

    $args = array(
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "show_ui" => true,
        "has_archive" => true,
        "show_in_menu" => true,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => false,
        "rewrite" => array( "slug" => "movies/%movie_name%", "with_front" => true ),
        "query_var" => true,
        "supports" => array( "title", "revisions" ),
        );
    register_post_type( "movie-special-features", $args );
4
  • 1
    Do you have debugging enabled?
    – Milo
    Apr 6, 2015 at 18:58
  • @Milo is right, if you enable debugging it will tell you exactly what the issue is.
    – Howdy_McGee
    Apr 6, 2015 at 19:01
  • Great...do I set the debug values in my functions.php or should I set it in the config file?
    – Mattaton
    Apr 6, 2015 at 19:03
  • Well, would you look at that. CPT names can't be more than 20 characters. Makes sense! THANKS!
    – Mattaton
    Apr 6, 2015 at 19:06

1 Answer 1

2

"movie-special-features" is longer than 20 chars. If you enable debug, you will get a message, these names are not allowed longer than 20 cars. Reference: https://codex.wordpress.org/Function_Reference/register_post_type

You can enable the debug mode in you wp-config.php with

define( 'WP_DEBUG', true );

Reference: https://codex.wordpress.org/WP_DEBUG

1
  • gladly found this quick! have to tell my client that "forschungseinrichtungen" is not possible. >.< Jun 10, 2020 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.