• I have a field group which consists of 20 fields structured like so:

    Item 1
    Content 1
    Item 2
    Content 2
    Item 3
    Content 3

    Etc.

    Items are text fields and Contents are WYSIWYG editors.

    I’ve set up a template so it will display in that manner as well. Item, Content, Item, Content etc.

    Two pages use this template. One page functions perfectly fine. However, the other page only functions fine up to the 6th item and content. When I start populating content after the 6th set, the item and content are inserted into the container for the 6th elements. So it starts displaying like this

    Item 6
    Item 7
    Item 8

    Content 6
    Content 7
    Content 8

    Unfortunately the site is private so I can’t send a link. This is the function that generates the code:

    function get_links_content() {
    	$fields = get_fields();
    
    	if( $fields )
    	{
    		foreach( $fields as $field_name => $value )
    		{
    			$field = get_field_object($field_name, false, array('load_value' => false));
    
    			if (stristr($field_name,'link_title') && !empty($value)) {
    				$linkC = str_replace(',', '', $value);
    				$linkQ = str_replace('?', '', $linkC);
    	            $link = str_replace(' ', '', $linkQ );
    	            ?>
    				<div class="tocSection"><h3 id="<?php echo $link; ?>"><?php echo $value; ?></h3>
    
    				<?php
    			}
    
    			if (stristr($field_name,'content') && !empty($value)) {
    
    			               echo $value;
    			               if ( is_page(53) ) {
       							 ?><a class="smoothscroll" title="Back to top of page" href="#page"><span class="fa fa-angle-up"></span> Back to Top</a>
       							 <?php
    							}
    							?>
    			               </div>
    
    				<?php
    
    			}
    
    		}
    	}
    }

    and this is the markup in the template:

    <div class="linksContent">
    						<?php get_links_content(); ?>
    					</div>

    Why would this happen? And why on one page using the template but not another? If I create a new page with the same template, it doesn’t happen.

    I’m a WP beginner so thanks in advance for your patience with me. I really appreciate any help!

    https://wordpress.org/plugins/advanced-custom-fields/

  • The topic ‘Fields generating inconsistent markup’ is closed to new replies.