Jump to content

Standard loop?


dtek516

Recommended Posts

Hi, I have a simple loop question:

 

I have 5 custom variables that are accessed with:

 

<?php echo get_field('image_1'); ?>

 

they contain a URL as their value. How can I loop through these variables and display this: 

 

<a href="<?php echo get_field('image_1'); ?>" rel="lightbox[<?php the_title(); ?>]"><img src="<?php echo get_field('image_1'); ?>"/></a>

if the value is true.

 

yet nothing if its not.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/249921-standard-loop/
Share on other sites

Here's what I've got...

 

<?php

for($i=1; $i<6; $i++){              //loop 5 times

if(get_field('image_' . $i)){      //check if there is an image on each iteration of the loop

echo' <a href="' . get_field('image_' . $i) . '" rel="lightbox[ ]"><img src="' . get_field('image_' . $i) . '"/>';  //output results

}

}

?>

 

now my problem is adding this:    rel="lightbox[<?php the_title();?>]" inside that echo. any idea?

Link to comment
https://forums.phpfreaks.com/topic/249921-standard-loop/#findComment-1283187
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.