无法启用功能图像


Unable to enable Feature Image

我会在前面说我不懂PHP 我一直在网上搜索一种方法,在我的帖子中启用"特写图像"。一些消息来源建议放置add_theme_support("张贴缩略图")在主题的functions.php文件中。没有成功。

我已经粘贴了下面functions.php的内容。感谢您提供的任何帮助!

<?php
//Repeating fields
include_once('acf-repeater/acf-repeater.php');
//Add custom styles to WP editor
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
function my_mce_buttons_2( $buttons ) {
    array_unshift( $buttons, 'styleselect' );
    return $buttons;
}
add_filter( 'tiny_mce_before_init', 'my_mce_before_init' );
add_theme_support( 'post-thumbnails' );
function my_mce_before_init( $settings ) {
    $style_formats = array(
        array(
            'title' => 'Theme Blue',
            'inline' => 'span',
            'classes' => 'theme-blue',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Blue (Background Colour)',
            'inline' => 'span',
            'classes' => 'theme-blue-bg',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Red',
            'inline' => 'span',
            'classes' => 'theme-red',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Red (Background Colour)',
            'inline' => 'span',
            'classes' => 'theme-red-bg',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Green',
            'inline' => 'span',
            'classes' => 'theme-green',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Green (Background Colour)',
            'inline' => 'span',
            'classes' => 'theme-green-bg',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Darker Green',
            'inline' => 'span',
            'classes' => 'theme-darker-green',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Darker Green (Background Colour)',
            'inline' => 'span',
            'classes' => 'theme-darker-green-bg',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Purple',
            'inline' => 'span',
            'classes' => 'theme-purple',
            'wrapper' => true
        ),
        array(
            'title' => 'Theme Purple (Background Colour)',
            'inline' => 'span',
            'classes' => 'theme-purple-bg',
            'wrapper' => true
        ),
        array(
            'title' => 'Solutions (Red Stats box)',
            'block' => 'div',
            'classes' => 'video-stats theme-red-bg',
            'wrapper' => true
        ),      
        array(
            'title' => 'Solutions (Green Stats box)',
            'block' => 'div',
            'classes' => 'video-stats theme-green-bg',
            'wrapper' => true
        ),  
        array(
            'title' => 'Solutions (Blue Stats box)',
            'block' => 'div',
            'classes' => 'video-stats theme-blue-bg',
            'wrapper' => true
        ),  
        array(
            'title' => 'Solutions (DarkerGreen Stats box)',
            'block' => 'div',
            'classes' => 'video-stats theme-darker-green-bg',
            'wrapper' => true
        ),  
        array(
            'title' => 'Solutions (Add Padding Below Last Stats box in group)',
            'selector' => 'div',
            'classes' => 'last-container'
        ), 
        array(
            'title' => 'Solutions (Enlarged Numbers)',
            'inline' => 'span',
            'classes' => 'highlight',
            'wrapper' => true
        ), 
        array(
            'title' => 'Increase Text Size',
            'inline' => 'span',
            'classes' => 'highlight',
            'wrapper' => true
        ), 
        array(
            'title' => 'Decrease Text Size (Source: etc.)',
            'inline' => 'span',
            'classes' => 'source',
            'wrapper' => true
        ), 
        array(
            'title' => 'Red Highlight',
            'inline' => 'span',
            'classes' => 'red-highlight',
            'wrapper' => true
        ),
        array(
            'title' => 'Quote',
            'selector' => 'p',
            'classes' => 'quote'
        ), 
        array(
            'title' => 'Author',
            'selector' => 'p',
            'classes' => 'author'
        ),
        array(
            'title' => 'List Spacer (apply to P above lists)',
            'selector' => 'p',
            'classes' => 'faux-list-header'
        ) 
    );
    $settings['style_formats'] = json_encode( $style_formats );
    return $settings;
}
add_editor_style('custom-editor-style.css');  
add_action( 'admin_init', 'add_my_editor_style' );
function add_my_editor_style() {
    add_editor_style();
}
function remove_acf_menu()
{
    $admins = array( 
        'admin'
    );
    $current_user = wp_get_current_user();
    if( !in_array( $current_user->user_login, $admins ) )
    {
        remove_menu_page('edit.php?post_type=acf');
        remove_menu_page('admin.php?page=wpfront-plugins');
        remove_menu_page('user-edit.php?user_id=1');
    }
}
add_action( 'admin_menu', 'remove_acf_menu', 999 );

您只是在调用中缺少了第二个参数:

add_theme_support( 'post-thumbnails', array( 'post' ) ); 

这将为帖子启用特色图片。如果您想将它们添加到页面上,请逐页更改帖子。

edit第二个参数需要是数组