Skip Navigation

[Closed] multiple images

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 11 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

This topic contains 4 replies, has 3 voices.

Last updated by AndrewSmithGKM 11 years, 7 months ago.

Assisted by: Caridad.

Author
Posts
#16043

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 ;/

#16098

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

#16128

@caridadz, That doesn't work :/

#16181

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

#16196

@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?

    The topic ‘[Closed] multiple images’ is closed to new replies.