2017-11-08 12 views

答えて

0

タグがあるかどうかは、has_tag()で確認できます。

<?php if(has_tag()) { ?> 
<div id="tags"> 
    <h4 class="tag-title">Tags</h4> 
    <?php the_tags('', ' ', '<br />'); ?> 
</div> 
<?php } ?> 
0

the_tagsの$ before、$ sep、$ afterパラメータとしてhtml要素を使用すると、子供が1人しかいない場合は#タグを非表示にすることができます。

この投稿を見る:Selector for when only one child exists in parent私は以下の例を思いついた。

<style> 
    .tags h4:nth-child(1):last-child{ 
     display: none; 
    } 
</style> 

<div class='tags' id='tags1'> 
    <h4>Some nonsense</h4> 
</div> 

<div class='tags' id='tags2'> 
    <h4>Some nonsense</h4> 
    <ul><li>Some</li><li>other</li></ul> 
</div> 
関連する問題