Hi, i want to build portfolio based on wp-types and jquery plugins. I created custom post type specially for viewing my projects. It contains tittle, tags, description and images. To display images I use nivo slider jquery plugin, everything works fine with this code in theme:
<?php echo(types_render_field("images", array())); ?>
But I also want to include shadowbox plugin, so I have to add links to all images. In simple, now I have this:
<img src="blablabla"></img><img src="blablabla"></img>
I want this:
<a href="blablabla"><img src="blablabla"></img></a><a href="blablabla"><img src="blablabla"></img></a>
I tried to add something like that:
<a href="<?php echo(types_render_field("images", array())); ?>"><?php echo(types_render_field("images", array("url" => "true"))); ?></a>
but it doesn't work, It displays links above images ;/
Dear Patryk,
You can get an array of field values and loop over it . This way you have more control over the output. Something like this:
<?php
$images = get_post_meta(get_the_ID(), 'wpcf-images');
foreach ($images as $image) {
echo '<a href="' . $image . '">' . $image . '</a>';
}
Regards,
Caridad
@caridadz, That doesn't work :/
Dear Andrew,
I just tried including that code in single.php, inside the loop and it worked with very little variations:
<?php
$images = get_post_meta(get_the_ID(), 'wpcf-images');
foreach ($images as $image) {
echo '<a href="' . $image . '"><img src="' . $image . '" /></a>';
}
?>
Please let me know if there is anything else that I can assist you with.
Regards.
Caridad
@caridadz I found a nice way to get the images into a list, in case you're using a slideshow that needs
<?php echo types_render_field('images', array('separator' => '
')); ?>
Does your code need to be within a loop to work?