0

我有一个 WordPress 网站,其中我为作者联系字段添加了一些额外的字段。有些人会使用 Google plus,但有些人不会。我不想有一个空的段落标签等。我似乎无法弄清楚如何编写一个有效的 if 语句。这就是我正在使用的。谢谢你的时间。

<?php if(get_the_author_meta('google')) ?> { ?>

    <p><?php the_author_meta('google'); ?></p>

<?php }

    else {
            // do nothing

} endif; ?>
4

2 回答 2

1
<?php if(get_the_author_meta('google')):  ?>

<p><?php the_author_meta('google'); ?></p>

<?php 

else: 
        // do nothing

 endif; ?>

Did you try this? Also, your code has the opening brace for 'if' without a php tag.

于 2013-06-18T00:49:52.193 回答
0

try this - and put a class of some sort on there to ensure it's not showing up in the spots where it's not filled in - a border or something?

<?php if (get_the_author_meta('google')) { ?>

    <p class="error"><?php the_author_meta('google') ?></p>

<?php }

else {

    // do nothing

} ?>

This seems to work. Maybe it's the endif ?

于 2013-06-18T00:48:26.307 回答