• Resolved dms92

    (@dms92)


    Hello,

    i created a custom post type, let’s refer to is as custom_post_01.
    At some point i was unable to update the existing posts or add new.

    I deactivated all plugins and checked again, but the issue was still there.

    So i tried changing the post’s name and slug and migrate posts to newly renamed post type was checked. The new custom posts, custom_post_02 worked fine, i can add new posts or update the old ones, and all the content was successfully migrated.

    The thing is, i need to work with the custom_post_01 name and slug, so i tried to rename and migrate the custom post again, check if it works.

    Nothing changed, custom_post_01 still cannot be updated or add new content.

    As i click the update button i get nothing as error, just nothing happens.
    On concole i get the following error:

    https://drive.google.com/file/d/1Q_HfsR_6RETi2UpEnG01OnR5L23QAhNL/view?usp=sharing

    Custom Post Type UI version: 1.9.0
    Wordpress version:5.7.1

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    What’s the actual post type slug that you’re wanting to use, that’s breaking things?

    Is it possible that you could use the renamed slug from here on out and then make use of the rewrite field to have the permalinks be back to the way they were for the original post type? Best of both worlds.

    Thread Starter dms92

    (@dms92)

    The actual slug is “exhibits”.

    The website is about a museum, so this slug is a must.

    I cannot do what you suggest and rewrite the posts types because new content will be added at any time, and not by me but by the museum staff.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    That would be the thing though, say you have the post type slug of “the_exhibits”, but the rewrite slug is “exhibits”. The permalinks would still be https://www.ourmuseum.com/exhibits/king-tut but at the code/query level at least with custom code, the post type slug would be specified with the_exhibits. Visually it’d be what you need, and there would be zero needing to set a setting each time a new exhibit is being added, by whoever. It’d just automatically be that for the permalink, and the content person would be none the wiser about this.

    That said though, I’m definitely willing to see if I can recreate what’s going on and attempt to dig in to this if you’re willing to visit the CPTUI > Tools menu item, and paste me the information in the “get info” tab. This will allow me to extract any post types and taxonomies you have registered with our plugin, so that I can import in to a local install as needed. It’d also allow me to see potentially conflicting plugins that may be adding to the issue.

    As is, I don’t think it’s anything to do specifically with what CPTUI does, and is likely more an issue internally to WordPress core for some reason.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Followup for myself as well as anyone stopping by, the errors in the doc file are pointing me to the post below and this heading: “Return Detailed Error Information from Request Validation”

    REST API Changes in WordPress 5.7

    It’s not an answer, but it is a lead for the moment.

    Thread Starter dms92

    (@dms92)

    Sure, i can give you the info from “Get code” tab.

    All Custom Post Type UI Post Types

    function cptui_register_my_cpts() {

    /**
    * Post Type: Exhibits.
    */

    $labels = [
    “name” => __( “Exhibits”, “hello-elementor” ),
    “singular_name” => __( “Exhibit”, “hello-elementor” ),
    ];

    $args = [
    “label” => __( “Exhibits”, “hello-elementor” ),
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “publicly_queryable” => true,
    “show_ui” => true,
    “show_in_rest” => true,
    “rest_base” => “”,
    “rest_controller_class” => “WP_REST_Posts_Controller”,
    “has_archive” => true,
    “show_in_menu” => true,
    “show_in_nav_menus” => true,
    “delete_with_user” => false,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => true,
    “rewrite” => [ “slug” => “exhibits”, “with_front” => true ],
    “query_var” => true,
    “menu_position” => 4,
    “supports” => [ “title”, “editor”, “thumbnail”, “excerpt”, “custom-fields” ],
    ];

    register_post_type( “exhibits”, $args );
    }

    add_action( ‘init’, ‘cptui_register_my_cpts’ );

    Exhibits Post Type

    function cptui_register_my_cpts_exhibits() {

    /**
    * Post Type: Exhibits.
    */

    $labels = [
    “name” => __( “Exhibits”, “hello-elementor” ),
    “singular_name” => __( “Exhibit”, “hello-elementor” ),
    ];

    $args = [
    “label” => __( “Exhibits”, “hello-elementor” ),
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “publicly_queryable” => true,
    “show_ui” => true,
    “show_in_rest” => true,
    “rest_base” => “”,
    “rest_controller_class” => “WP_REST_Posts_Controller”,
    “has_archive” => true,
    “show_in_menu” => true,
    “show_in_nav_menus” => true,
    “delete_with_user” => false,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => true,
    “rewrite” => [ “slug” => “exhibits”, “with_front” => true ],
    “query_var” => true,
    “menu_position” => 4,
    “supports” => [ “title”, “editor”, “thumbnail”, “excerpt”, “custom-fields” ],
    ];

    register_post_type( “exhibits”, $args );
    }

    add_action( ‘init’, ‘cptui_register_my_cpts_exhibits’ );

    All Custom Post Type UI Taxonomies

    function cptui_register_my_taxes() {

    /**
    * Taxonomy: Exhibits type.
    */

    $labels = [
    “name” => __( “Exhibits type”, “hello-elementor” ),
    “singular_name” => __( “Exhibit type”, “hello-elementor” ),
    ];

    $args = [
    “label” => __( “Exhibits type”, “hello-elementor” ),
    “labels” => $labels,
    “public” => true,
    “publicly_queryable” => true,
    “hierarchical” => true,
    “show_ui” => true,
    “show_in_menu” => true,
    “show_in_nav_menus” => true,
    “query_var” => true,
    “rewrite” => [ ‘slug’ => ‘exhibit_type’, ‘with_front’ => true, ‘hierarchical’ => true, ],
    “show_admin_column” => true,
    “show_in_rest” => true,
    “rest_base” => “exhibit_type”,
    “rest_controller_class” => “WP_REST_Terms_Controller”,
    “show_in_quick_edit” => true,
    ];
    register_taxonomy( “exhibit_type”, [ “exhibits” ], $args );
    }
    add_action( ‘init’, ‘cptui_register_my_taxes’ );

    Exhibits type Taxonomy

    function cptui_register_my_taxes_exhibit_type() {

    /**
    * Taxonomy: Exhibits type.
    */

    $labels = [
    “name” => __( “Exhibits type”, “hello-elementor” ),
    “singular_name” => __( “Exhibit type”, “hello-elementor” ),
    ];

    $args = [
    “label” => __( “Exhibits type”, “hello-elementor” ),
    “labels” => $labels,
    “public” => true,
    “publicly_queryable” => true,
    “hierarchical” => true,
    “show_ui” => true,
    “show_in_menu” => true,
    “show_in_nav_menus” => true,
    “query_var” => true,
    “rewrite” => [ ‘slug’ => ‘exhibit_type’, ‘with_front’ => true, ‘hierarchical’ => true, ],
    “show_admin_column” => true,
    “show_in_rest” => true,
    “rest_base” => “exhibit_type”,
    “rest_controller_class” => “WP_REST_Terms_Controller”,
    “show_in_quick_edit” => true,
    ];
    register_taxonomy( “exhibit_type”, [ “exhibits” ], $args );
    }
    add_action( ‘init’, ‘cptui_register_my_taxes_exhibit_type’ );

    i use hello elementor theme Version: 2.3.1 and elementor pro Version 3.2.1

    Regards

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    As is, I’m not managing to recreate, though I have only set up matching post type/taxonomy settings within my local install.

    We have already noted above that you deactivated every other plugin except CPTUI and it persisted. Have we tried temporarily changing themes to something like one of the defaults?

    Thread Starter dms92

    (@dms92)

    Just checked themes / plugins again.
    Noticed that elementor is the problem.
    Everything works fine after i deactivate elementor, no matter the theme :/

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Well at least we know the source of the issue. May be worth checking with their support team about things. Feel free to let us know what they say, in case it’s something we can help with in some way.

    Thread Starter dms92

    (@dms92)

    Sure, i let you know as soon as i get a reply!

    Thread Starter dms92

    (@dms92)

    Hello,

    after further investigation with elementor support we now know it’s a API bug.

    If show rest api is set to false, everything works great.

    Elementor has nothing do to with that.

    I set the api to false and it’s all good!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Only potential downside to that is if in the future you want/need the WP Core block editor experience for the post type. However, if you’re using Elementor for the foreseeable future anyway, then no big deal here.

    Glad a solution was found.

    Thread Starter dms92

    (@dms92)

    I use the elementor to build the theme/templates for single post, but the actual content will be added with block editor. Text mostly.

    Any chance i have any problems in the future?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Nothing that I’m presently aware of.

    Thread Starter dms92

    (@dms92)

    Great!
    Thank you for your time!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Custom post type cannot be updated or add new posts’ is closed to new replies.