Get multiple custom field values and output in an html table
-
I have 2 meta keys with multiple values each one. This is my code:
<?php $cod = get_post_meta($post->ID, 'codigo', false); ?> <?php $tam = get_post_meta($post->ID, 'tamanho', false); ?> <?php if ( $cod ) : ?> <?php if ( $tam ) : ?> <table cellpadding="0" cellspacing="0"> <caption>Description</caption> <tbody> <tr> <td>Code:</td> <?php foreach ( $cod as $cods ) : ?> <td><?php echo $cods; ?></td> <?php endforeach; ?> </tr> <tr> <td>Size:</td> <?php foreach ( $tam as $tams ) : ?> <td><?php echo $tams; ?></td> <?php endforeach; ?> </tr> </tbody> </table> <?php else : ?> <?php endif; endif; ?>
On the page it shows like this:
Key 1 | value1 | value2 | value3 ... Key 2 | value1 | value2 | value3 ...
Is there a way to output values vertically?
Key 1 | Key 2 value 1 | value 1 value 2 | value 2 value 3 | value 3
Thanks for now.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get multiple custom field values and output in an html table’ is closed to new replies.