-1

I am using advanced custom fields plugin with Wordpress trying to echo out a simple image using the code provided in their instructions.

Its throwing me 2 errors for this code,

  • illegal string offset 'url'.
  • illegal string offset 'alt'.

Has anyone encountered this before?

    <?php $image = get_field('top-section-img'); ?>
    <?php if(!empty($image)) : ?>
        <img class="service-top-right-image animation-duration" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    <?php endif; ?> 
Eli Himself
  • 652
  • 2
  • 6
  • 17
  • Possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – rnevius Jan 21 '16 at 23:54

1 Answers1

0

In line 2 you have to change </php to <?php

fusion3k
  • 11,259
  • 4
  • 22
  • 42
  • that was a typo when copying, thanks for noticing. However this doesnt fix the error. – Eli Himself Jan 22 '16 at 12:12
  • You have to post more of your code. `$image` is a string or an array? If is it a string, `$image['url']` and `$image['alt']` doesn't works fine. – fusion3k Jan 22 '16 at 12:42