Need help with syntax of conditional category statement
-
I’m trying to get WordPress to print out an attribution from a custom field if the post is in a category of “news”, and not otherwise. So the logic would be, “If category = “news,” print attribution (e.g., New York Times) and number of comments. Else, print only number of comments.”
I tried this, but it didn’t work:
<?php if ( in_category( '3' )) { echo 'From <?php if ( function_exists( 'get_custom_field_value' ) ) get_custom_field_value( 'Attribution', true ); ?> | <?php comments_popup_link('No comments', '1 comment ?', '% comments ?'); ?>'; } else { echo '<?php comments_popup_link('No comments', '1 comment ?', '% comments ?'); ?>' } ?>
…but then, not being a PHP’er, I didn’t think it would. But I hope someone can tell from the kludge above what the intent was.
Another way to do this, I think, would be to simply test if the custom field exists, and print out different lines accordingly. But I don’t know how to do that, either.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Need help with syntax of conditional category statement’ is closed to new replies.