Skip Navigation

[Resolved] Index is out of sync somehow?

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 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 3 replies, has 2 voices.

Last updated by jamesM-2 11 years ago.

Assisted by: Caridad.

Author
Posts
#86773

Hi guys, I'm trying to create a thumbnail gallery using the following code:

                        <?php
							echo(types_render_field( "vehicle-images", array( "alt" => "Product image",
								"width" => "454", "height" => "454", "proportional" => "true", 'index' => 0 ) ));
						?>

It's grabbing the thumbnail images perfectly, but the link is out of sync and not linking to the same image as displayed by the thumbnail and I can't figure out why, been racking my brains over it for a while now so would really appreciate some help.

Cheers

#86776

Ignore that code, my copy and pasting skills failed. The code I'm refering to is:

<?php $images = get_post_meta(get_the_ID(), 'wpcf-vehicle-images');
							for ($index = 0; $index < count($images); $index++) {
							$image = $images[$index];
							$thumb = types_render_field('vehicle-images', array('index' => $index, 'width' => '105', 'proportional' => 'true'));
							echo '<div class="span3"><a href="' . $image . '">' . $thumb . '</a></div>';
							}
						?>
#86979

Dear James,

There is an extra meta key holding the order that you aren't processing. Can you try with this code instead?

<?php $images = get_post_meta(get_the_ID(), 'wpcf-vehicle-images');
                            for ($index = 0; $index < count($images); $index++) {
                            $image = types_render_field('vehicle-images', array('index' => $index, 'raw' => 'true', 'proportional' => 'true'));
                            $thumb = types_render_field('vehicle-images', array('index' => $index, 'width' => '105', 'proportional' => 'true'));
                            echo '<div class="span3"><a href="' . $image . '">' . $thumb . '</a></div>';
                            }
                        ?>

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#87008

That's perfect thanks!

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.