user editable post type description

Support MB Settings Page user editable post type descriptionResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28592
    Aaron KesslerAaron Kessler
    Participant

    I am trying to make the post type description user editable. While I am able to access the settings-page data via rwmb_meta('_prefix_classic_editor', ['object_type' => 'setting'], 'posttype_description') inside a template like archive.php, I can't inside my register post types function like so:

    
    function prefix_register_post_types()
    {
        $cpt_labels = [...];
    
        register_post_type('cpt', [
            'label' => esc_html__('cpts', '_textdomain'),
            'labels' => $cpt_labels,
            'description' => rwmb_meta('prefix_classic_editor', ['object_type' => 'setting'], 'posttype_description'),
            'public' => true,
            'hierarchical' => false,
            'exclude_from_search' => false,
            'publicly_queryable' => true,
            'show_ui' => true,
            'show_in_nav_menus' => true,
            'show_in_admin_bar' => true,
            'show_in_rest' => true,
            'query_var' => true,
            'can_export' => true,
            'delete_with_user' => true,
            'has_archive' => true,
            'rest_base' => '',
            'show_in_menu' => true,
            'menu_icon' => 'dashicons-awards',
            'menu_position' => 5,
            'capability_type' => 'post',
            'supports' => ['title', 'editor', 'thumbnail', 'excerpt'],
            'taxonomies' => [],
            'rewrite' => [
                'with_front' => false,
            ],
        ]);
    }
    
    add_action('init', 'prefix_register_post_types');
    

    any idea on how to accomplish this?

    #28597
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The Meta Box core class hooks to the action init with the priority 20 after register the post type so the helper function rwmb_meta() does not work. You can use the WordPress function get_option() to get the settings page value.

    #28608
    Aaron KesslerAaron Kessler
    Participant

    This worked, thx a lot.
    The documention does not mention a usecase like this, where we can't use rwmb_meta(), but get_option()

    #28612
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks for your feedback.

    I will update the documentation to explain this case.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.