<?php if( strlen(the_content()) > 0 ) {?>
<a href="<?php the_permalink();?>"><?php the_title(\'<h2>\',\'</h2>\'); ?></a>
<?php } else { ?>
<?php the_title(\'<h2>\',\'</h2>\'); ?>
<?php } ?>
有人有什么建议吗?如果_content的字符串长度大于0,则显示POST,否则不显示
1 个回复
SO网友:kero
get_
是你的朋友。the_content()
已输出内容,而get_the_content()
返回它(以便检查长度并决定是否输出)。
$content = get_the_content();
if (strlen($content) > 0) {
//..
} else {
//..
}
结束