Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

ACF array quit working on new server WordPress

  • SOLVED

I've got an Advanced Custom Fields (ACF) checkbox array that shows an image or images based on what is checked on a custom post type. The code works fine on my old VPS and on my shared hosting servers. However, it does not work on my new VPS (same VPS host).

The old VPS is Debian 7.4 and the new is 8.X. I setup each VPS server, and I just think I'm missing something PHP related.

Here's the code that isn't working now:


<?php

$values = get_field('badges');

if(in_array("member", $values )){
?>
<div class="team-badge"><img src="<?php echo plugins_url();?>/team-members/assets/images/badge-member.png"></div>
<?
}

if(in_array("star", $values )){
?>
<div class="team-badge"><img src="<?php echo plugins_url();?>/team-members/assets/images/badge-star.png"></div>
<?
}

?>


Here are links to my PHP configurations (web print out):

http://www.oilygurus.com/test.php (this one works)
http://oilysites.com/test.php (this one doesn't work)

If I remove the above code, the page loads, and all other ACF fields load fine. If I leave the code in, the page loads until it hits that code, and then nothing else on the page displays.


Answers (2)

2015-08-25

Ross Wilson answers:

It looks like short_open_tag is turned off in your new setup and you are using <? in your code.


Kyler Boudreau comments:

Oh okay, cool. How do I enable that, or rather turn it on?


Ross Wilson comments:

So either in your code use <?php instead of <? or in your php.ini file set the short_open_tag to true. If you are on a shared hosting company sometimes you can do this in your control panel, or by dropping a file into the root directory of your website. Who is your host and I bet we can look it up.


Kyler Boudreau comments:

Ross -- thanks dude. The short_open_tag was the ticket. Really appreciate it!

2015-08-26

Arnav Joy answers:

here is the correct code


<?php



$values = get_field('badges');



if(in_array("member", $values )){

?>

<div class="team-badge"><img src="<?php echo plugins_url();?>/team-members/assets/images/badge-member.png"></div>

<?php

}



if(in_array("star", $values )){

?>

<div class="team-badge"><img src="<?php echo plugins_url();?>/team-members/assets/images/badge-star.png"></div>

<?php

}



?>