I'm trying to call WordPress's 'the_time' using a conditional statement that checks the category. I want to call the custom field 'event_date' if the category is '3' and 'the_time()' if the c开发者_Go百科ategory is '4'... This is what I have, and it echoes fine if I use "is_single()" instead of "is_category()" but for some I'm getting no echo when I use "is_category()"... any ideas?
<?php
if (is_category('4')) {
echo "<span>";
the_time('');
echo "</span>";
} elseif (is_category('3')) {
echo "<span>";
get_post_meta ('event_date');
echo "</span>";
} else {
echo "<p>Pedro offers you his protection.</p>";
} ?>
In this instance you want to use in_category
instead of is_category
.
精彩评论