Title: Repeating Data weird behavior
Last modified: August 20, 2016

---

# Repeating Data weird behavior

 *  [chavo](https://wordpress.org/support/users/chavo/)
 * (@chavo)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/repeating-data-weird-behavior/)
 * Hi. I’m using a function I found here [http://www.kevinleary.net/multiple-fields-groups-wordpress-custom-field-template-plugin/](http://www.kevinleary.net/multiple-fields-groups-wordpress-custom-field-template-plugin/)
   to get repeating data.
 * Mi goal is to give to the administrator the hability to generate as many banners
   as he wants with a combo of custom fields.
 * Mi CFT template code (spanish) looks like this (notice I don’t use blank=true):
 *     ```
       [Banner]
       type = fieldset_open
       legend = Banner
       multiple = true
       multipleButton = true
   
       [¿El banner debe tener link?]
       type = radio
       value = Sí # No
   
       [Link para el banner]
       type = text
       size = 100
       after = Ingresar url del link con http://
   
       [Etiqueta para el link]
       type = text
       size = 100
       after = Texto (tooltip) que se va a mostrar cuando el cursor pase por encima del link.
   
       [¿Abrir en nueva ventana?]
       type = radio
       value = Sí # No
   
       [Imagen para el banner]
       type = file
   
       [Titulo para el banner]
       type = text
       size = 100
       after = Sólo si el banner es un banner de imagen y texto html
   
       [Subtitulo para el banner]
       type = text
       size = 100
       after = Sólo si el banner es un banner de imagen y texto html
   
       [Breve texto para el banner]
       type = textarea
       rows = 4
       cols = 40
       after = Sólo si el banner es un banner de imagen y texto html
   
       [Banner]
       type = fieldset_close
       ```
   
 * The code into my theme looks like this:
 *     ```
       <?php
           // Get all duplucate fields from the database and store in array
       	$cft_groups = get_cft_repeating_data('Banner');
       	// Display groups
       	foreach ($cft_groups as $s => $v) {
       		// First check for data then define variables
       		if(!empty($cft_groups[$s]['Imagen para el banner']))
       			$bannerHome = $cft_groups[$s]['Imagen para el banner'];
   
       		if( !empty($cft_groups[$s]['Etiqueta para el link']) )
               	$etiquetaLink = $cft_groups[$s]['Etiqueta para el link'];	
   
               if( !empty($cft_groups[$s]['Titulo para el banner']) )
                   $titulo = $cft_groups[$s]['Titulo para el banner'];			
   
               if( !empty($cft_groups[$s]['Subtitulo para el banner']) )
               	$subtitulo = $cft_groups[$s]['Subtitulo para el banner'];
   
               if( !empty($cft_groups[$s]['Breve texto para el banner']) )
               	$texto = $cft_groups[$s]['Breve texto para el banner'];
   
       		$mostrarLink  = $cft_groups[$s]['¿El banner debe tener link?'];
   
       		if( !empty($cft_groups[$s]['Link para el banner']) )
               	$link = $cft_groups[$s]['Link para el banner'];
   
       		$abrirLink  = $cft_groups[$s]['¿Abrir en nueva ventana?'];
   
       		// Output HTML for a group<br />
   
       			// SI HAY UNA IMAGEN, ABRO EL BANNER
       			if(isset($bannerHome)) echo '<div class="postBanner">';
       			// SI TIENE LINK, ABRO LA ETIQUETA
       			//if($mostrarLink === "Sí") echo '<a href="'.$link.'" title="'.$etiquetaLink.'">';
       			if($mostrarLink === "Sí") echo '<a href="'.$link.'">';			
   
       			// SI HAY TEXTOS, ABRO EL CONTENEDOR DE LOS TEXTOS
       			if(isset($titulo) || isset($subtitulo) || isset($texto)) echo '<span class="textoBanner">';
       			// muestro los textos
   
       			if(isset($titulo))  echo '<h2>' .$titulo. '</h2>';
       			if(isset($etiquetaLink))  echo '<h2>' .$etiquetaLink. '</h2>';
       			if(isset($subtitulo))  echo '<h3>' .$subtitulo. '</h3>';
       			if(isset($texto))  echo '<p>' .$texto. '</p>';
            		// CIERRO EL CONTENEDOR DE LOS TEXTOS
       			if(isset($titulo) || isset($subtitulo) || isset($texto)) echo '</span>';
       			// SI HAY UNA IMAGEN, LA MUESTRO
       			if(isset($bannerHome)) echo wp_get_attachment_image($bannerHome, "Full");
   
       			// SI TIENE LINK, CIERRO LA ETIQUETA
       			if($mostrarLink === "Sí") echo '</a>';
       			// SI HAY UNA IMAGEN, CIERRO EL BANNER
       			if(isset($bannerHome)) echo '</div>';
       	}
       	?>
       ```
   
 * If I put a subtitle ($subtitulo) in just once field but not in both, the same
   subtitle (even if one field is empty) are displayed in frontpage in both banners.
   Also, if I put a text ($texto) in the second field, but not first, when uptading
   page, the data is asigned to first text field.
    If I put text into both fields,
   everything works ok. It looks like if is mandatory to insert data into all fields(
   and that’s no my goal because I want to give the hability to generate different
   kind of banners -with title or without title, with link or not, etc-). Another
   weird behavior is that in frontpage sometimes I get text data inverted (I mean:
   seconde banner title asigned to first image and viceversa).
 * I have no idea why is this happening.
 * Sorry for my bad english.
 * Thaks in advance.
 * [http://wordpress.org/extend/plugins/custom-field-template/](http://wordpress.org/extend/plugins/custom-field-template/)

Viewing 1 replies (of 1 total)

 *  [difreo](https://wordpress.org/support/users/difreo/)
 * (@difreo)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/repeating-data-weird-behavior/#post-3606366)
 * “notice I don’t use blank=true”. Use blank=true.

Viewing 1 replies (of 1 total)

The topic ‘Repeating Data weird behavior’ is closed to new replies.

 * ![](https://ps.w.org/custom-field-template/assets/icon-256x256.png?rev=1966286)
 * [Custom Field Template](https://wordpress.org/plugins/custom-field-template/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-field-template/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-field-template/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-field-template/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-field-template/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-field-template/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [difreo](https://wordpress.org/support/users/difreo/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/repeating-data-weird-behavior/#post-3606366)
 * Status: not resolved