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 have few custom field assigned for each post, like: "Club" with value "club1" "Date" with value "date1" and so on...

Now, I want to display from all the custom fields just those 2 " club" and "date".

This is my markup :

                    <div class="meta-container"><?php the_meta(); ?></div>

The problem with this, is that is retrieving all the custom fields and I don't want this. I was thinking to add css psedoselector like nth:child(n) but I'm sure that I can do this with this function. Thank you!

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You should use get_post_meta() twice (Ref to your other question):

<?php
  echo get_post_meta( get_the_ID(), 'club', true ); 
  echo '<br />';
  echo get_post_meta( get_the_ID(), 'date', true ); 
?>
share|improve this answer
add comment

Oddly enough, one of your tags is exactly what you need! You're looking for WordPress' get_post_meta function: http://codex.wordpress.org/Function_Reference/get_post_meta

Within the loop, it would look something like this:

<?php echo get_post_meta(get_the_ID(), 'Club', true); ?>
share|improve this answer
    
I've tried also this, but is not working, now it doesn't display anything. –  Alecs Apr 16 '13 at 0:03
    
My bad, it was a cache problem, it's working but I can not retrieve two values: I've tried this: <?php echo get_post_meta(get_the_ID(), 'CLUB','DATES', true); ?> –  Alecs Apr 16 '13 at 11:30
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.