Fresh install, after adding a custom post type: Rank Math error

#13400
  • Resolved Sneakerbaron
    Rank Math free

    Dear support,

    Today I started a fresh WordPress install, and immediately added a Custom Post Type and Rank Math.
    However, after saving the custom code in functions.php. I get an error that originates from the Rank Math plug-in.

    Notice: CMB2_Field::__construct() was called with a parameter that is deprecated since version 2.2.3! Using the "default" field parameter as a callback has been deprecated in favor of the "default_cb" parameter. in /data/sites/web/WEBSITE/subsites/dev.WEBSITE.nl/wp-content/plugins/seo-by-rank-math/vendor/cmb2/cmb2/includes/CMB2_Base.php on line 456
    
    Warning: Cannot modify header information - headers already sent by (output started at /data/sites/web/WEBSITE/subsites/dev.WEBSITE.nl/wp-content/plugins/seo-by-rank-math/vendor/cmb2/cmb2/includes/CMB2_Base.php:456) in /data/sites/web/WEBSITE/subsites/dev.WEBSITE.nl/wp-admin/includes/misc.php on line 1196
    S

    This is the code for the custom post type registration:

    /* Register custom post type 'blog' */
    function blog() {
    
    	$labels = array(
    		'name'                  => _x( 'Blogberichten', 'Post Type General Name', 'cpt-namespace' ),
    		'singular_name'         => _x( 'Blogbericht', 'Post Type Singular Name', 'cpt-namespace' ),
    		'menu_name'             => __( 'Blogberichten', 'cpt-namespace' ),
    		'name_admin_bar'        => __( 'Blogbericht', 'cpt-namespace' ),
    		'archives'              => __( 'Blog archieven', 'cpt-namespace' ),
    		'attributes'            => __( 'Blog attributen', 'cpt-namespace' ),
    		'parent_item_colon'     => __( 'Parent blog', 'cpt-namespace' ),
    		'all_items'             => __( 'Alle blogs', 'cpt-namespace' ),
    		'add_new_item'          => __( 'Nieuw blogbericht toevoegen', 'cpt-namespace' ),
    		'add_new'               => __( 'Nieuwe toevoegen', 'cpt-namespace' ),
    		'new_item'              => __( 'Nieuw blogberichten', 'cpt-namespace' ),
    		'edit_item'             => __( 'Bewerk blogbericht', 'cpt-namespace' ),
    		'update_item'           => __( 'Update blogbericht', 'cpt-namespace' ),
    		'view_item'             => __( 'Bekijk blogbericht', 'cpt-namespace' ),
    		'view_items'            => __( 'Bekijk blogberichten', 'cpt-namespace' ),
    		'search_items'          => __( 'Zoek blogbericht', 'cpt-namespace' ),
    		'not_found'             => __( 'Not found', 'cpt-namespace' ),
    		'not_found_in_trash'    => __( 'Not found in Trash', 'cpt-namespace' ),
    		'featured_image'        => __( 'Featured Image', 'cpt-namespace' ),
    		'set_featured_image'    => __( 'Set featured image', 'cpt-namespace' ),
    		'remove_featured_image' => __( 'Remove featured image', 'cpt-namespace' ),
    		'use_featured_image'    => __( 'Use as featured image', 'cpt-namespace' ),
    		'insert_into_item'      => __( 'Insert into item', 'cpt-namespace' ),
    		'uploaded_to_this_item' => __( 'Uploaded to this item', 'cpt-namespace' ),
    		'items_list'            => __( 'Blogberichten list', 'cpt-namespace' ),
    		'items_list_navigation' => __( 'Items list navigation', 'cpt-namespace' ),
    		'filter_items_list'     => __( 'Filter items list', 'cpt-namespace' ),
    	);
    	$args = array(
    		'label'                 => __( 'Blogbericht', 'cpt-namespace' ),
    		'description'           => __( 'Blogberichten', 'cpt-namespace' ),
    		'labels'                => $labels,
    		'supports'              => array( 'title', 'editor', 'thumbnail', 'comments', 'custom-fields' ),
    		'taxonomies'            => array( 'category', 'post_tag' ),
    		'hierarchical'          => false,
    		'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,
    		'capability_type'       => 'post',
    	);
    	register_post_type( 'blog', $args );
    
    }
    add_action( 'init', 'blog', 0 );

    I repeat that this is a fresh install (empty theme also), with ONLY Rank Math activated, and this custom post type.
    When I remove the Custom Post Type registration code from the functions.php file, the error is gone.

    I really love the plug-in, and would love to keep using it. How do I fix this error?

    Kind regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I have been able to replicate this error notice on my end and this has been submitted to our dev team for closer investigation.

    We will be getting back to you in a short while.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hello Sneakerbaron,

    The blog function which you are using is causing the problem. You will see this warning in any plugin or theme which uses the CMB2 package. Please replace your code with the following one:

    
    add_action( 'init', function() {
    	$labels = array(
    		'name'                  => _x( 'Blogberichten', 'Post Type General Name', 'cpt-namespace' ),
    		'singular_name'         => _x( 'Blogbericht', 'Post Type Singular Name', 'cpt-namespace' ),
    		'menu_name'             => __( 'Blogberichten', 'cpt-namespace' ),
    		'name_admin_bar'        => __( 'Blogbericht', 'cpt-namespace' ),
    		'archives'              => __( 'Blog archieven', 'cpt-namespace' ),
    		'attributes'            => __( 'Blog attributen', 'cpt-namespace' ),
    		'parent_item_colon'     => __( 'Parent blog', 'cpt-namespace' ),
    		'all_items'             => __( 'Alle blogs', 'cpt-namespace' ),
    		'add_new_item'          => __( 'Nieuw blogbericht toevoegen', 'cpt-namespace' ),
    		'add_new'               => __( 'Nieuwe toevoegen', 'cpt-namespace' ),
    		'new_item'              => __( 'Nieuw blogberichten', 'cpt-namespace' ),
    		'edit_item'             => __( 'Bewerk blogbericht', 'cpt-namespace' ),
    		'update_item'           => __( 'Update blogbericht', 'cpt-namespace' ),
    		'view_item'             => __( 'Bekijk blogbericht', 'cpt-namespace' ),
    		'view_items'            => __( 'Bekijk blogberichten', 'cpt-namespace' ),
    		'search_items'          => __( 'Zoek blogbericht', 'cpt-namespace' ),
    		'not_found'             => __( 'Not found', 'cpt-namespace' ),
    		'not_found_in_trash'    => __( 'Not found in Trash', 'cpt-namespace' ),
    		'featured_image'        => __( 'Featured Image', 'cpt-namespace' ),
    		'set_featured_image'    => __( 'Set featured image', 'cpt-namespace' ),
    		'remove_featured_image' => __( 'Remove featured image', 'cpt-namespace' ),
    		'use_featured_image'    => __( 'Use as featured image', 'cpt-namespace' ),
    		'insert_into_item'      => __( 'Insert into item', 'cpt-namespace' ),
    		'uploaded_to_this_item' => __( 'Uploaded to this item', 'cpt-namespace' ),
    		'items_list'            => __( 'Blogberichten list', 'cpt-namespace' ),
    		'items_list_navigation' => __( 'Items list navigation', 'cpt-namespace' ),
    		'filter_items_list'     => __( 'Filter items list', 'cpt-namespace' ),
    	);
    	$args = array(
    		'label'                 => __( 'Blogbericht', 'cpt-namespace' ),
    		'description'           => __( 'Blogberichten', 'cpt-namespace' ),
    		'labels'                => $labels,
    		'supports'              => array( 'title', 'editor', 'thumbnail', 'comments', 'custom-fields' ),
    		'taxonomies'            => array( 'category', 'post_tag' ),
    		'hierarchical'          => false,
    		'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,
    		'capability_type'       => 'post',
    	);
    	register_post_type( 'blog', $args );
    }, 0 );
    

    This should fix the issue.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Fresh install, after adding a custom post type: Rank Math error’ is closed to new replies.