Support

Account

Home Forums Add-ons Flexible Content Field Flexible Content Field missing first piece of content on Front-end.

Solved

Flexible Content Field missing first piece of content on Front-end.

  • Hello,

    I’m using the Flexible Content Field to allow my client to create a sidebar on my their site (heading, textarea, link, etc.). If I go to a page in the admin and add let’s say 4 pieces of content in that new sidebar, on the front-end it shows 3 pieces of content. It always skips the first piece of content I entered. I can hack it by adding a blank piece of content as the first item then I see all 4 pieces of content. Please see the attached sample of the issue for more details.

    This is happening on all pages of the site, regardless of how many pieces of content I create in the sidebar. This happens regardless of any combination I use as well. I have even removed all the flexible content fields and tried just 1 and the issue remains. I’m using the latest version of WordPress(3.6), Advanced Custom Fields(4.2.2) and Flexible Content Field(1.0.2).

    Here is the code I’m using on the sidebar template to display the flexible content fields:

    <?php while(has_sub_field('create_sidebar')): ?>
    		<?php if(get_row_layout() == 'side_t'): // layout: Textarea ?>
    			<p><?php the_sub_field('side_t_text'); ?></p>	
    		<?php elseif(get_row_layout() == 'side_h'): // layout: Heading ?>
    			<h3><?php the_sub_field('side_h_text'); ?></h3>		
    		<?php elseif(get_row_layout() == 'side_f'): // layout: File ?>
    			<a href="<?php the_sub_field('side_f_file'); ?>" target="_blank" class="button"><i class="icon-file"></i> <?php the_sub_field('side_f_text'); ?></a>
    		<?php elseif(get_row_layout() == 'side_l'): // layout: Link ?>
    			<?php $linkText = get_sub_field('side_ltext'); ?>
    			<a href="<?php the_sub_field('side_link'); ?>" class="button"><i class="icon-chevron-right"></i> <?php echo($linkText); ?></a>
    		<?php elseif(get_row_layout() == 'side_a'): // layout: Anchor ?>
    			<?php $anchorText = get_sub_field('side_a_text'); ?>
    			<a href="#<?php the_sub_field('side_anchor'); ?>" class="button"><i class="icon-chevron-down"></i> <?php echo($anchorText); ?></a>
    		<?php endif; ?>
    	<?php endwhile; ?>

    Thanks for any help!

  • Hi @bcoy

    Is it possible that you have used the has_sub_field more than once? Perhaps in an if statement somewhere?

  • You are absolutely right! Right before that code I had a check to see if the side should show up at all <?php if(has_sub_field('create_sidebar')): ?>. I removed it and the first item showed up right away. I can work my way around that. Thank you very much!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Flexible Content Field missing first piece of content on Front-end.’ is closed to new replies.