tags:

views:

34

answers:

1

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 category 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>";
} ?>
+3  A: 

In this instance you want to use in_category instead of is_category.

nickohrn
Now my trouble is that 'get_post_meta ('event_date');' is returning the error: Warning: Missing argument 2 for get_post_meta() in xxxxxx/html/wp-includes/post.php on line 666
Brian
get_post_meta takes three arguments as follows: get_post_meta($post_id, $meta_name, $single = false); If you don't provide the third argument, you'll get back an array, so your call here should probably be get_post_meta(get_the_ID(), 'event_date', true);
nickohrn
that doesn't quite work, what ended up working is: " echo get_post_meta($post->ID, 'event_date', true); "
Brian