0

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>";
} ?>
1
  • Tell us what "it's breaking down" means and maybe we can help you. For the record, "it's broken" will never be an adequate description of a problem. Commented Feb 22, 2010 at 20:11

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

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
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);
that doesn't quite work, what ended up working is: " echo get_post_meta($post->ID, 'event_date', true); "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.