Custom fields and tag display on single.php
-
Hello,
I’ve successfully displayed several custom fields & customized tags on my main loop (on index.php).
However, when using the same code to display them in my single.php page, nothing shows !
Any hint, help, welcome – thanks you!
My custom field contains an image URL.
<img src="<?php bloginfo('url'); ?><?php $key="thumb"; echo get_post_meta($post->ID, $key, true); ?>" alt="<?php the_title(); ?>" />
My tags are customized with CSS classes (using their ID).
<?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { if ($tag->term_id == 3) { echo '<li class="webdesign">' . $tag->name . '</li>'; } if ($tag->term_id == 6) { echo '<li class="css">' . $tag->name . '</li>'; } if ($tag->term_id == 5) { echo '<li class="ecommerce">' . $tag->name . '</li>'; } if ($tag->term_id == 7) { echo '<li class="photo">' . $tag->name . '</li>'; } if ($tag->term_id == 8) { echo '<li class="strategy">' . $tag->name . '</li>'; } if ($tag->term_id == 9) { echo '<li class="cd">' . $tag->name . '</li>'; } if ($tag->term_id == 10) { echo '<li class="dev">' . $tag->name . '</li>'; } if ($tag->term_id == 11) { echo '<li class="forum">' . $tag->name . '</li>'; } if ($tag->term_id == 12) { echo '<li class="illustration">' . $tag->name . '</li>'; } if ($tag->term_id == 13) { echo '<li class="branding">' . $tag->name . '</li>'; } if ($tag->term_id == 14) { echo '<li class="copywriting">' . $tag->name . '</li>'; } if ($tag->term_id == 15) { echo '<li class="cms">' . $tag->name . '</li>'; } if ($tag->term_id == 16) { echo '<li class="accessibility">' . $tag->name . '</li>'; } } } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom fields and tag display on single.php’ is closed to new replies.