Featured image column for default posts types

Support MB Admin Columns Featured image column for default posts types

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29071
    info@j0e.org[email protected]
    Participant

    Hello,
    can I use MB to add a column with the featured image to the default posts and pages listings?

    thanks
    Jochen

    #29079
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can use the custom admin columns to show the featured image in the listing posts/pages. Follow this documentation https://docs.metabox.io/extensions/mb-admin-columns/#custom-admin-columns

    class My_Featured_Image_Columns extends \MBAC\Post {
        public function columns( $columns ) {
            $columns  = parent::columns( $columns );
            $position = 'before';
            $target   = 'title';
            $this->add( $columns, 'featured_image', 'Featured Image', $position, $target );
            // Add more if you want
            return $columns;
        }
        public function show( $column, $post_id ) {
            switch ( $column ) {
                case 'featured_image':
                    the_post_thumbnail( [40, 40] ); //here
                    break;
                // More columns
            }
        }
    }

    With the MB Builder, you can create a field with ID _thumbnail_id then show it as an admin column.

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