Home › Forums › Front-end Issues › 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; ?>
The topic ‘Warning: Illegal string offset 'url'’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.