0

There is a div element in header.php which I want to show only in post page. The div should not be visible on home page or 404 page or category or pages or tag page. It should be only visible post page.

The method I am thinking is using css. The div element will have a class. Let the class be hide-container this class is set to display:none;. . the trick is show another div container in post page.

Like this below code which shows the class in singles.

<div class="hide-container <?php if(is_singular() ) { ?>container<?php } ?>">

The above code will have worked, but it shows the div element on all pages except home page. I only want the div to be displayed in post page.

thanks in advance.

4

1 回答 1

0

使用is_home()条件标签

<div class="social-tools <?php if(is_home() ) { ?>container<?php } ?>">

即使它是这样写的 -is_home()显示帖子页面

看看这个问题

于 2013-07-10T21:43:26.990 回答