【问题标题】:wordpress ignores featured imagewordpress 忽略特色图片
【发布时间】:2013-05-03 08:34:31
【问题描述】:

我基于经典的二十一主题创建了一个 wordpress 主题。 我在 functions.php 中更改了标题图像的大小,但除此之外,我并没有弄乱自定义标题的东西。现在,当我将特色图像分配给页面时,wordpress 会忽略它,而只显示在标题设置中选择的背景。 图像的大小似乎与问题无关。我试过使用精确的图像尺寸和更大的图像,它们总是被忽略...

如果您能提供帮助,谢谢!

PS。这里是网站的链接:http://stuck-mueller.de/beta/

这是来自functions.php的代码:

// The custom header business starts here.

$custom_header_support = array(
    // The default image to use.
    // The %s is a placeholder for the theme template directory URI.
    'default-image' => '%s/images/headers/path.jpg',
    // The height and width of our custom header.
    'width' => apply_filters( 'twentyten_header_image_width', 960 ),
    'height' => apply_filters( 'twentyten_header_image_height', 240 ),
    // Support flexible heights.
    'flex-height' => true,
    // Don't support text inside the header image.
    'header-text' => false,
    // Callback for styling the header preview in the admin.
    'admin-head-callback' => 'twentyten_admin_header_style',
);

add_theme_support( 'custom-header', $custom_header_support );

if ( ! function_exists( 'get_custom_header' ) ) {
    // This is all for compatibility with versions of WordPress prior to 3.4.
    define( 'HEADER_TEXTCOLOR', '' );
    define( 'NO_HEADER_TEXT', true );
    define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
    define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
    define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
    add_custom_image_header( '', $custom_header_support['admin-head-callback']   );
    add_custom_background();
}

// We'll be using post thumbnails for custom header images on posts and pages.
// We want them to be 940 pixels wide by 198 pixels tall.
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );

【问题讨论】:

    标签: wordpress header twenty-ten-theme


    【解决方案1】:

    您不需要 apply_filters() 只需将宽度和高度分配给整数,例如:

    'width' => 960,
    'height' => 240,
    

    Check out the codex here for more info

    【讨论】:

      猜你喜欢
      • 2014-09-28
      • 2011-03-11
      • 2019-07-31
      • 2012-04-02
      • 2016-11-21
      • 2015-04-28
      • 2015-02-02
      • 2019-03-22
      • 1970-01-01
      相关资源
      最近更新 更多