Admin Columns Not Showing Data

Support MB Admin Columns Admin Columns Not Showing Data

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18113
    Jacob HillJacob Hill
    Participant

    Hello,

    The admin columns are appearing, but no data is shown in the columns for some reason... When I click on an entry, the data show in the fields, but the data doesn't appear in the wp-admin interface for that post type. Help! Info is below, but please let me know if you need anything else.

    Here is the CPT:

    // Creates the CPT.
    add_action( 'init', 'rj9z6t_register_cpt_access_logs' );
    function rj9z6t_register_cpt_access_logs()
    {
        $args = array (
            'label' => esc_html__( 'Access Logs', 'rj9z6t-cpt-access-logs' ),
            'labels' => array(
                'menu_name' => esc_html__( 'Access Logs', 'rj9z6t-cpt-access-logs' ),
                'name_admin_bar' => esc_html__( 'Access Log', 'rj9z6t-cpt-access-logs' ),
                'add_new' => esc_html__( 'Add new', 'rj9z6t-cpt-access-logs' ),
                'add_new_item' => esc_html__( 'Add new Access Log', 'rj9z6t-cpt-access-logs' ),
                'new_item' => esc_html__( 'New Access Log', 'rj9z6t-cpt-access-logs' ),
                'edit_item' => esc_html__( 'Edit Access Log', 'rj9z6t-cpt-access-logs' ),
                'view_item' => esc_html__( 'View Access Log', 'rj9z6t-cpt-access-logs' ),
                'update_item' => esc_html__( 'Update Access Log', 'rj9z6t-cpt-access-logs' ),
                'all_items' => esc_html__( 'All Access Logs', 'rj9z6t-cpt-access-logs' ),
                'search_items' => esc_html__( 'Search Access Logs', 'rj9z6t-cpt-access-logs' ),
                'parent_item_colon' => esc_html__( 'Parent Access Log', 'rj9z6t-cpt-access-logs' ),
                'not_found' => esc_html__( 'No Access Logs found', 'rj9z6t-cpt-access-logs' ),
                'not_found_in_trash' => esc_html__( 'No Access Logs found in Trash', 'rj9z6t-cpt-access-logs' ),
                'name' => esc_html__( 'Access Logs', 'rj9z6t-cpt-access-logs' ),
                'singular_name' => esc_html__( 'Access Log', 'rj9z6t-cpt-access-logs' ),
            ),
            'public' => true,
            'exclude_from_search' => true,
            'publicly_queryable' => false,
            'show_ui' => true,
            'show_in_nav_menus' => true,
            'show_in_admin_bar' => false,
            'show_in_rest' => false,
            'menu_icon' => 'dashicons-list-view',
            'capability_type' => 'post',
            'hierarchical' => false,
            'has_archive' => false,
            'query_var' => false,
            'can_export' => true,
            'supports' => array(
                'title',
                'author',
            ),
            'rewrite' => array(
                'slug' => 'access-logs',
            ),
        );
    
        register_post_type( 'rj9z6t-access-logs', $args );
    }

    Here is the meta box:

    // Creates the fields.
    add_filter( 'rwmb_meta_boxes', 'rj9z6t_register_meta_box_access_logs', 20 );
    function rj9z6t_register_meta_box_access_logs( $meta_boxes )
    {
        $prefix = '_rj9z6t_access_logs_';
    
        $meta_boxes[] = array (
            'title' => esc_html__( 'Access Log', 'rj9z6t-meta-box-access-log' ),
            'id' => 'access-log',
            'post_types' => array(
                0 => 'rj9z6t-access-logs',
            ),
            'context' => 'after_title',
            'priority' => 'high',
            'fields' => array(
                array (
                    'id' => $prefix . 'content_title',
                    'type' => 'text',
                    'name' => esc_html__( 'Content Title', 'rj9z6t-meta-box-access-log' ),
                    'tooltip' => esc_html__( 'The title of the content that was visited.', 'rj9z6t-meta-box-access-log' ),
                    'required' => 1,
                    'size' => 100,
                    'admin_columns' => array(
                        'position'   => 'replace title',
                        'filterable' => true,
                    ),
                ),
                array (
                    'id' => $prefix . 'url',
                    'type' => 'text',
                    'name' => esc_html__( 'URL', 'rj9z6t-meta-box-access-log' ),
                    'tooltip' => esc_html__( 'The url of the content that was visited.', 'rj9z6t-meta-box-access-log' ),
                    'required' => 1,
                    'size' => 100,
                    'admin_columns' => array(
                        'position'   => 'before author',
                        'filterable' => true,
                    ),
                ),
                array (
                    'id' => $prefix . 'ip_address',
                    'type' => 'text',
                    'name' => esc_html__( 'IP Address', 'rj9z6t-meta-box-access-log' ),
                    'tooltip' => esc_html__( 'The user\'s IP address.', 'rj9z6t-meta-box-access-log' ),
                    'required' => 1,
                    'size' => 100,
                    'admin_columns' => array(
                        'position'   => 'before author',
                        'filterable' => true,
                    ),
                ),
            ),
            'text_domain' => 'rj9z6t-meta-box-access-log',
            
        );
    
        return $meta_boxes;
    }
    #18128
    Jacob HillJacob Hill
    Participant

    Any update? Let me know if you need any more info.

    #18145
    Anh TranAnh Tran
    Keymaster

    Hi Jacob,

    Sorry for the delay. I've tested with your code and see it works. Please see this video:

    https://www.loom.com/share/d1f84cdd5d144e0fbd1b1d597bd6a326

    #18178
    Jacob HillJacob Hill
    Participant

    Thank you for testing! I believe there may be a conflict somewhere, I'll work on identifying that tonight.

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