Moved WP to another domain -> Can’t use function return value

I am moving a WordPress site to another domain, and one of the errors that has stopped the prosess is the following:

Fatal error: Can’t use function return value in write context in
/home/spectrapride/public_html/wp-content/themes/spectranorge/single-4.php
on line 28

Read More

I have tried searching it up, but I can’t figure out what is wrong.

Here is my PHP, starting from line 27:

<div class="col-md-6 videowidth">
    <?php if(!empty(types_render_field('embedded-media-field', array('raw'=>'true')))){?>
    <a id="teksttilvideo" onclick="myFunction()" href="javascript:void(0);"><div class="teksttilvideo">
    <?php echo __( '<img src="http://spectra-norge.no/wp-content/themes/spectranorge/img/spillavvideo_thumb.png" width="100%" class="tvshadow">'); ?>
    </div></a>
    <div class="tvshadow" id="videoholder" style="display:none;">
    <dd><?php echo(types_render_field('embedded-media-field', array("output" => "html"))); ?></dd>
    <?php }?>
    </div>
</div>

I have checked and ’embedded-media-field’ is not empty. And by removing the following:

<?php if(!empty(types_render_field('embedded-media-field', array('raw'=>'true')))){?>
    <a id="teksttilvideo" onclick="myFunction()" href="javascript:void(0);"><div class="teksttilvideo">
    <?php echo __( '<img src="http://spectra-norge.no/wp-content/themes/spectranorge/img/spillavvideo_thumb.png" width="100%" class="tvshadow">'); ?>
     </div></a>

And change display:none to display:block, the video shows up with no errors. However, the deleted part is important to the site.

The irony is that everything works perfectly fine on my other domain…

Do you have any ideas?

Related posts

1 comment

  1. Turns out the problem was with the PHP version mentioned by @Levi Zoesch.

    The problem was that empty is not a function, but a language construct (Source). The way I wrote it was supported by PHP 5.5+, and not older. Therefor the fatal error appeared.

    To solve the problem I made a variable of the function:

    <?php if(!empty(types_render_field('embedded-media-field', array('raw'=>'true')))){?>
    

    Into:

    <?php $renderfieldmedia = types_render_field('embedded-media-field', array('raw'=>'true'))?>
    <?php if(!empty($renderfieldmedia)){?>
    

    Problem solved.

Comments are closed.