Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using list category posts and would like to display several custom fields, but not all together.

I have used a template to display the list in a table, and have custom fields for country, county and town that I would like to display in individual cells. These are the only custom fields I will be using, so I can hard code the names in the template is necessary.

Thanks.

share|improve this question
add comment

1 Answer

You can use get_post_meta(). This is the codex article: http://codex.wordpress.org/Function_Reference/get_post_meta

It sounds like each of the custom field values you want to display would only contain one result (one country, one town etc). In that case you'd use something like this in your template, wherever you want to display the value:

<?php if ( get_post_meta($post->ID, 'country', true) ) : ?>
    <?php echo get_post_meta($post->ID, 'country', true) ?>
<?php endif; ?>

Hope this helps, best of luck!

share|improve this answer
    
Thanks that's just what I was after. –  mary hughes Apr 4 '12 at 13:33
    
Great! If this works for you, you can mark the answer as accepted so other people don't spend time on it. :) –  Michelle Apr 4 '12 at 21:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.