我正在尝试创建一个查询
如果“FeaturedQuote”自定义字段中有值,则显示
<h3 class="featuredquote"><blockquote><span class="bqstart">“</span><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, \'FeaturedQuote\', true);
wp_reset_query();
?>
<span class="bqend">”</span></blockquote>
</h3>
如果不是,则显示:
<img src="<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, \'InsertFullImg\', true);
wp_reset_query();
?>">
我做不好!
谢谢
SO网友:fuxia
将第一次检查的返回值分配给变量,并测试其中是否有内容:
if ( $quote = get_post_meta( get_the_ID(), \'FeaturedQuote\', TRUE ) )
{
?><h3 class="featuredquote"><?php the_title(); ?></h3>
<blockquote><span class="bqstart">“</span><?php
echo $quote;
?>
<span class="bqend">”</span></blockquote>
<?php
}
elseif ( $img = get_post_meta( get_the_ID(), \'InsertFullImg\', TRUE ) )
{
echo "<img src=\'$img\' alt=\'\'>";
}
注,a
<h3>
不能是的父级
<blockquote>
. 标题只能包含内联元素。