Conditional Tags In WordPress

Posted by

Hi,

These are the Conditional Tags that can be used within your wordpress blog:

is_home()
is_single()
is_page()
is_category()
is_author()
is_date()
is_year()
is_month()
is_day()
is_time()
is_archive()
is_search()
is_paged()
is_404()

We can use any of these conditional tags in the post meta area. For example, I want to display comments button but I do not want to appear on the single page because the comments are displayed on that page. At that time I also wants to display edit button on the single page but I do not want to dispay it on any other pages. For this we can use this condtional tags code:

<?php if (is_single()){ ?> <?php edit_post_link(__(“*Edit*”), ”); ?> <?php } else { ?> | <?php comments_popup_link(‘0 comments’, ‘1 comment’, ‘% comments’); ?> <?php } ?>

That’s it!

Thanks,

Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.