0
我在我的主題中創建了一個category.php模板,並希望某些代碼檢測被查看的類別是否爲父類。如果是,那麼我想設置一個變量爲一個值,如果不是,我想將其設置爲另一個值。這可能嗎?檢測類別是否是父類 - 在wordpress模板category.php
我在我的主題中創建了一個category.php模板,並希望某些代碼檢測被查看的類別是否爲父類。如果是,那麼我想設置一個變量爲一個值,如果不是,我想將其設置爲另一個值。這可能嗎?檢測類別是否是父類 - 在wordpress模板category.php
試試這個,並在其中賦值。
<?php $this_category = get_category($cat); ?>
<?php if ($this_category->category_parent == 0) { ?>
<!-- If Parent -->
<?php } else { ?>
<!-- Else This -->
<?php } ?>