Не могу вывести миниатюру
-
Пытаюсь вывести миниатюру в колонку таблицы. Что делаю не так?
Рейтинг отображается.<?php private $meta_settings = array( 'title' => 'Рейтинг:', 'slug' => 'rating', 'input_type' => 'input', 'post_type' => 'portfolio', 'empty_message' => '0' ); private $cb_meta_settings = array( 'title' => 'Миниатюра', 'slug' => 'thumbnail', 'input_type' => 'input', 'post_type' => 'portfolio', 'empty_message' => 'Нет миниатюры' ); /** * Initial setup. Called by get_instance. */ protected function init() { add_filter( 'manage_'.$this->meta_settings['post_type'].'_posts_columns', array( $this, 'edit_meta_columns' ), 1 ); add_action( 'manage_'.$this->meta_settings['post_type'].'_posts_custom_column', array( $this, 'manage_meta_columns' ), 10, 2 ); add_filter( 'manage_'.$this->cb_meta_settings['post_type'].'_posts_columns', array( $this, 'cb_edit_meta_columns' ), 1 ); add_action( 'manage_'.$this->cb_meta_settings['post_type'].'_posts_custom_column', array( $this, 'cb_manage_meta_columns' ), 10, 2 ); } /** * Add column for Meta on CPT */ function edit_meta_columns( $columns ) { $columns[$this->meta_settings['slug']] = $this->meta_settings['title']; return $columns; } function cb_edit_meta_columns( $columns ) { $columns[$this->cb_meta_settings['slug']] = $this->cb_meta_settings['title']; return $columns; } /** * Populate column */ function manage_meta_columns( $column, $post_id ) { global $post; switch( $column ) { /* If displaying our custom meta column. */ case $this->meta_settings['slug'] : /* Get the post meta. */ $custom_meta = get_post_meta( $post_id, $this->meta_settings['slug'], true ); /* If no custom meta is found, output a default message. */ if ( empty( $custom_meta ) ) echo $this->meta_settings['empty_message']; else echo '<div class="storm-meta-input" id="storm-meta-input-' . $post_id . '">' . get_post_meta( $post_id, $this->meta_settings['slug'], true ) . '</div>'; break; default : break; } } function cb_manage_meta_columns( $column, $post_id ) { global $post; switch( $column ) { case $this->cb_meta_settings['slug'] : $cb_custom_meta = get_post_meta( $post_id, $this->cb_meta_settings['slug'], true ); if ( empty( $cb_custom_meta ) ) echo $this->cb_meta_settings['empty_message']; else echo '<div class="storm-meta-input" id="storm-meta-input-' . $post_id . '">' . get_post_meta( $post_id, $this->cb_meta_settings['slug'], true ) . '</div>'; break; default : break; } }
Просмотр 3 ответов — с 1 по 3 (всего 3)
Просмотр 3 ответов — с 1 по 3 (всего 3)
Тема «Не могу вывести миниатюру» закрыта для новых ответов.