Support

Account

Home Forums Add-ons Repeater Field Is it possible to get images from default language from repeater fields?

Unread

Is it possible to get images from default language from repeater fields?

  • I have created Flexible content and Repeater fields for pages where I have to insert desired number of images for slider and 1 text field. This repeats itself so there can be many components like that on pages (usually 3).
    So, the ending result looks something like this:

    – 1st slider:
    – image1, image2, image3
    – text
    – 2nd slider:
    – image1, image2
    – text
    – 3rd slider:
    – image1, image2, image3
    – text

    The problem is that currently there are 3 languages active (WPML is installed) and I have to add or replace images for each of 3 languages. This is becoming hard to maintain since there are more pages than was initially planned and images are prone to changes.
    Is it possible for code to display only images from default language? In that case I would need to add or replace images only for default language .

    `while ( have_rows(‘flex_slider’) ) : the_row();
    $image = get_sub_field(‘flex_slider_img’); `

    Here is the full code (I have tried to clear it a bit)

    
    <?php $flexcontent_index = 1; ?>
    <?php while ( have_rows('flex_content') ) : the_row(); ?>
    
    <?php 
    if (get_row_layout() == 'slider_and_content') {
    	if( have_rows('flex_slider') ): ?>
    
    	<div class="col-md-8">
    			<div id="slider-flex-<?php echo $flexcontent_index; ?>" class="carousel slide" data-ride="carousel">
    				<div class="carousel-inner">
    					<?php while ( have_rows('flex_slider') ) : the_row(); ?>
    					<?php 
    					// Here get default image
    					$image = get_sub_field('flex_slider_img'); 
    					?>
    					<div class="carousel-item <?php echo get_row_index() === 1 ? 'active' : ''; ?>">
    						<?php $img_src = wp_get_attachment_image_src($image['ID'], 'full'); ?>
    						<img src="<?php echo $img_src[0]; ?>" />
    					</div>
    					<?php endwhile; ?>
    				</div>
    				<a class="carousel-control" href="#slider-flex-<?php echo $flexcontent_index; ?>" data-slide="prev">
    					Prev
    				</a>
    				<a class="carousel-control" href="#slider-flex-<?php echo $flexcontent_index; ?>" data-slide="next">
    					Next
    				</a>
    			</div>
    	</div>
    
    	<?php endif; ?>
    
    	<div class="col-md-4">
    		<?php echo get_sub_field('flex_content_inside'); ?>
    	</div>
    	$flexcontent_index++;
    }

    Here is the code https://pastebin.com/raw/bv6XEq87

Viewing 1 post (of 1 total)

The topic ‘Is it possible to get images from default language from repeater fields?’ is closed to new replies.