P
P
Programmer2021-10-16 15:46:10
WordPress
Programmer, 2021-10-16 15:46:10

Why is it giving an error?

<div class="header__logo">
                        <a href="#">
                            <?php 
                            $image = get_field('logo');
                            if( !empty($image) ): 
                            ?>
    <img src="<?php echo $image['url']; ?>" alt="StoriesCafe"/>

<?php endif; ?>
                        </a>


I wanted to connect the image like this, but it gives an error

616ac9890e149452290670.png

616ac99093078561072885.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
inFureal, 2021-10-16
@Manvel2019

The get_field function internally tries to get the logo key (which doesn't exist) from an array or ArrayAccess descendant. So he writes that illegal offset. And what exactly is wrong there, smoke the documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question