基本上我想做的是:显示youtube缩略图。如果没有youtube缩略图->显示文章的特色图像。如果没有特征图像->显示回退图像。
然而,似乎我做错了什么,因为网页显示为空白。
<?php
// Check if the post has a Youtube thumbnail (using custom field video_url)
if get_post_meta($post->ID,\'video_url\',true)
echo \'<img src="http://img.youtube.com/vi/\' . get_post_meta($post->ID,\'video_url\',true) . \'/0.jpg"/>\';
// Check if the post has a Post Thumbnail assigned to it
else ( has_post_thumbnail() ) {
echo \'<a href="\' . get_permalink($post->ID) . \'" >\';
the_post_thumbnail(\'frontpage-thumb\');
echo \'</a>\';
// If the post does not have a featured image then display the fallback image
} else {
echo \'<a href="\' . get_permalink($post->ID) . \'" ><img src="\'. get_stylesheet_directory_uri() . \'/img/fallback-featured-image-index.jpg" /></a>\';}
?>
显示带有自定义字段的youtube缩略图的常规代码为<img src="http://img.youtube.com/vi/<?php echo get_post_meta($post->ID,\'video_url\',true);?>/0.jpg"/>
我就是不能让它和条件语句一起工作。。。