无法启用要素图像

时间:2015-06-24 15:44:04

标签: php thumbnails

我将通过说我不懂PHP来作为序言。 我一直在网上寻找一种方法来启用一个特色图像"在我的帖子中。有几位消息人士建议在我主题的 functions.php 文件中放置 add_theme_support('缩略图后')。没有成功。

我已粘贴下面 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 );

1 个答案:

答案 0 :(得分:0)

你刚刚错过了来自通话的第二个参数:

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

这将为帖子启用精选图片。如果您想在页面上添加它们,请将帖子更改为页面。

编辑第二个参数需要是一个数组