Combining 2 Multiple Custom Fields
-
I am trying to combine 2 multiple custom fields to display photos and add 2 seperate links to the photos i.e. photo1 to link to link1 and photo2 to link to link2. This is what I did –
1. Created a custom field “photo”
2. Created a custom field “link”
3. 2 values each for “photo” and “link”Code I used –
<?php $links = get_post_meta($post->ID, "link", false) ?> <?php $photos = get_post_meta($post->ID, "photo", false) ?> <?php $title = get_the_title(); ?> <?php foreach($photos as $photo) { foreach($links as $link) echo "\n<p>\n <a href='".$link."' target='_blank'> <img src='".$photo."' alt='".$title."' title='".$title."' </a> \n</p>\n"; } ?>
This shows each image twice with the links. Can someone please help.
Also if I have 3 values for “photo” and 1 value for “link” how can I link the second photo only with the “link” value?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Combining 2 Multiple Custom Fields’ is closed to new replies.