Viewing 1 reply thread
  • Author
    Posts
    • #1434
      ingrid
      Member
      Warning: array_keys() expects parameter 1 to be array, string given in /Users/user/website/example.com/wp-content/plugins/piklist/includes/class-piklist.php on line 731
      
      Warning: Invalid argument supplied for foreach() in /Users/user/website/example.com/wp-content/plugins/piklist/includes/class-piklist.php on line 244

      I am getting these warnings on a page where I am displaying the output of a nested add more.

      These warnings are being shown because of these two lines:

      $brown_description = get_post_meta($post->ID, 'brown_description', true);
      
      piklist('addmore-box-template', array('data' => $brown_description, 'loop' => 'data'));

      Why is this code causing warnings?

      Especially given that this code (below) does not cause any errors!

      $box = get_post_meta($post->ID, 'box_content', true);
      piklist('addmore-box-template', array('data' => $box, 'loop' => 'data'));

      Does it have anything to do with the fact that $brown_description is inside the $box array?

      Thanks!

    • #1436
      Marcus
      Member

      I’m just guessing but your piklist function is expecting $box and $brown_description to be arrays.
      Yet in your get_post_metas, you are not loading them as arrays but as singles. (adding ‘, true’ to any get_post_meta request makes it a single not an array, default is ‘get_post_meta(id, meta_key, single=false’)

      Just a guess from looking at your code.

      Marcus

Viewing 1 reply thread
  • You must be logged in to reply to this topic.