Support

Account

Home Forums Front-end Issues Warning: Illegal string offset 'url'

Solved

Warning: Illegal string offset 'url'

  • WP: 4.5.3
    ACF: 5.3.9.2

    I’m experiencing Illegal string offset ‘url’ error.

    <br /> <b>Warning</b>: Illegal string offset 'url' in <b>/home/....</b> on line <b>108</b><br />

    Code:

    
    				<?php 
                    $retheading = get_field('ret_heading',163); 
                    $retcont = get_field('ret_content',163);            
                    $leftcont = get_field('left_column_content',163);            
                    $centercont = get_field('center_column_content',163);            
                    $rightcont = get_field('right_column_content',163);            
                    $botcont = get_field('bottom_content',163);            
    
                    if( !empty($retcont) ): ?>    
                    	<section id="retinal">    
                        	<div class="container">    
                    		<h3><?php echo $retheading; ?></h3>
                            <?php echo $retcont; ?>
                            <div class="col-sm-4">
    							<?php echo $leftcont; ?>
                            </div>
                            <div class="col-sm-4">
                            <?php if( !empty($centercont) ): ?>
                            	<img src="<?php echo $centercont['url']; ?>" />
                            <?php endif; ?>
                            </div>
                            <div class="col-sm-4">
                            	<?php echo $rightcont; ?>
                            </div>
                            <?php echo $botcont; ?>
                            </div>
                    	</section>
                    <?php endif; ?>

    Line 108 is:

    <?php if( !empty($centercont) ): ?>
                            	<img src="<?php echo $centercont['url']; ?>" />
                            <?php endif; ?>

    Field setting for “center_column_content” is:

    LABEL: Center Column Content
    NAME: center_column_content
    TYPE: Image
    RETURN VALUE: Image URL

    All field names are unique from others

    I’ve read several forum posts regarding ‘Illegal string offset ‘url’ and have tried the following:

    Changing the variable(s)/field name(s)
    Switching between Image ID and Image URL to post Image
    Disabled/Enabled ACF

    I’m not having any other issues with posting images with unique variables.

    Other options to try?

  • if you are returning the url then the line should be

    
    <?php if( !empty($centercont) ): ?>
         <img src="<?php echo $centercont; ?>" />
    <?php endif; ?>
    
  • (facepalm)
    I tend to get those two types of usages confused.

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

The topic ‘Warning: Illegal string offset 'url'’ is closed to new replies.