Can anyone give me the specific code for my specific example?
maybe this (inside a loop) [untested]:
<?php if($released = get_post_meta($post->ID, 'Released', true)) : ?>
<div class="entry-date">
<?php echo $released; ?>
</div><!-- .entry-date -->
<?php endif; ?>
I now have a further question – how to make the resulting value a clickable link that returns all posts with that field? In other words, exactly the same as the clickable tags you get normally in posts?
What values do these custom fields (with key Released) have? Dates? in what format?
Under what url do you want to have this?
They are all text fields – I basically use these fields as tags. So it’s a games site and some of the custom fields are:
‘Genre’, ‘Developer’, ‘Released’ etc
Now if I had those fields as tags, the normal wordpress behaviour (I think) is to show them in the post as links, and if you click on a particular tag, it returns all posts with that tag. That’s the kind of behaviour I’d like with these fields, if possible š
Then why not use tags, categories or a custom taxonomy?
http://codex.ww.wp.xz.cn/Taxonomies
OK, well with tags, how can I retrieve the tags one by one? So that I can encase each on within a different css class?
http://codex.ww.wp.xz.cn/Function_Reference/get_the_tags
Try it with this (inside the loop):
<?php
$posttags = get_the_tags();
if ($posttags) :
foreach($posttags as $tag) : ?>
<a href="<?php echo get_tag_link($tag->term_id); ?>" class="posttag-<?php echo $tag->slug; ?>"><?php echo $tag->name; ?></a>
<?php endforeach; ?>
<?php endif; ?>
This will give each tag a class of “posttag-{slug}”. If a tag name is “Developer” the link will get a class of “posttag-developer”.