Custom model - Position in Menu

Support MB Custom Table Custom model - Position in Menu

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30725
    hlikeshlikes
    Participant

    Hi, I am following the docs here: https://docs.metabox.io/extensions/mb-custom-table/#custom-models

    But not sure about what to specify for the "parent" parameter, which is described as "if you want to show model as a sub-menu". What do I need to specify if I want to place the link under an existing menu?

    Thanks,
    M.

    #30730
    Long NguyenLong Nguyen
    Moderator

    Hi,

    It works like the sub-menu page in WordPress

    The slug name for the parent menu (or the file name of a standard WordPress admin page)

    For example, if you want to show the transaction under the Page menu, assign the setting parent to this slug edit.php?post_type=page

    function prefix_register_transaction_model() {
        mb_register_model( 'transaction', [
            'table'  => 'transactions',
            'labels' => [
                'name'          => 'Transactions',
                'singular_name' => 'Transaction',
            ],
            'menu_icon' => 'dashicons-money-alt',
            'parent' => 'edit.php?post_type=page'
        ] );
    }

    Get more details on the documentation
    https://developer.wordpress.org/reference/functions/add_submenu_page/#user-contributed-notes

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