我想在标题中显示两幅图像。
功能。php:
define(\'BP_DTHEME_DISABLE_CUSTOM_HEADER\', true);
//add support for featured images with post type of header image
add_theme_support( \'post-thumbnails\', array(\'header_image\') );
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
register_post_type( \'header_image\',
array(
\'labels\' => array(
\'name\' => __( \'Header Image\' ),
\'singular_name\' => __( \'Header Image\' )
),
\'public\' => true,
\'has_archive\' => true,
\'supports\' => array(\'thumbnail\') //(featured image, current theme must also support post-thumbnails)
)
);
}
标题。php:
<?php
$args = array( \'post_type\' => \'header_image\');
$header_images = new WP_Query( $args );
?>
<?php foreach($image as $header_images){ ?>
<div class="header-image">
<?php echo get_the_post_thumbnail($image, \'thumbnail\'); ?>
</div>
<?php
}
?>
现在我有两个问题:
1) 我收到一个php错误:警告:为标头中的foreach()提供的参数无效。php
2) 我应该在何处将两个图像路径附加到header\\u image post type数组,以便我可以引用header中的两个图像。php?
感谢您的回复