我正在尝试修改一个主题,使其与我的自定义字段(我在页面上输入的大多数数据都使用ACF)一起用于一个有歌词的站点。原始代码如下:
$metro_creativex_posttitle = get_the_title();
$metro_creativex_feat_image = wp_get_attachment_image_src(
get_post_thumbnail_id( $post->ID ),
\'single-post-thumbnail\'
);
if(isset($metro_creativex_feat_image[0])):
echo \'<div class="img">\'.get_the_post_thumbnail().\'</div>\';
endif;
这是content.php
显示类别页面中的帖子。现在,由于我的帖子没有任何特色图片,只有一个或两个通过自定义字段显示的图片,我的第一个意图是用单封面艺术替换“自定义缩略图”,所以首先我替换了get_post_thumbnail
使用get_field
, 它至少可以检测出歌曲是否有一张封面图片:$metro_creativex_posttitle = get_the_title();
$metro_creativex_feat_image = wp_get_attachment_image_src(
$post->ID,
get_field(\'sd_single_img\'),
\'single-post-thumbnail\'
);
if(isset($metro_creativex_feat_image[0])):
echo \'<div class="img">\'.get_the_post_thumbnail().\'</div>\';
endif;
我现在的主要问题是,我不明白我必须在echo
要使其显示实际图像,而不仅仅是类别菜单上歌曲标题上方的空白:Link to my page我怎样才能修复它?