Custom Fields
Re-Envisioned
Support MB Admin Columns Featured image column for default posts types

  • Creator
    Topic
  • #29071
    info@j0e.org
    Participant

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

    thanks
    Jochen

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #29079
    Long 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 1 replies (of 1 total)
  • You must be logged in to reply to this topic.