Reputation: 2289
I'm using the Advanced Custom Fields Pro plugin and its Flexible Fields
I'm getting the following PHP warning for each layout related to the implode
I'm using on the $displayCat
variable:
Warning: implode() [function.implode]: Invalid arguments passed in /server-path/wp-content/themes/theme-name/page-home.php on line XX
I thought it was because $displayCat
wasn't always an array, so tried to put $displayCat = array();
but that didn't eliminate the warnings.
Any ideas?
if( have_rows('home_content') ):
// loop through the rows of data
while ( have_rows('home_content') ) : the_row();
// 1x1 Nav
if( get_row_layout() == '1x1_nav' ):
$img = get_sub_field('img');
$alt = get_sub_field('alt');
$url = get_sub_field('url');
$displayCat = implode('" "', get_sub_field('display_cat'));
Upvotes: 0
Views: 2281
Reputation: 27092
get_sub_field()
doesn't return an array...it returns a string. Since you're trying to make an array out of individual strings, you should do the following:
$displayCat[] = get_sub_field('display_cat');
This will append each 'display_cat'
sub-field to the $displayCat
array.
Then, outside of your while()
loop, you can implode(' ', $displayCat);
Upvotes: 1