Title: [Plugin: Posts 2 Posts] PHP Warning with WP_DEBUG On
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] PHP Warning with WP_DEBUG On

 *  Resolved [Zack Katz](https://wordpress.org/support/users/katzwebdesign/)
 * (@katzwebdesign)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-php-warning-with-wp_debug-on/)
 * `Warning: Invalid argument supplied for foreach() in [...]/wp-content/plugins/
   posts-to-posts/core/type.php on line 51`
 * Adding the following to the `expand_fields()` method on a new line fixes this
   PHP warning.
 *     ```
       private function expand_fields( $fields ) {
       	if(!is_array($fields)) { return array(); } // New code
       	foreach ( $fields as &$field_args )
       ```
   
 * Please add this fix in the next release. Thanks!
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-php-warning-with-wp_debug-on/#post-2783949)
 * Why exactly would you pass `'fields' => NON-ARRAY-VALUE` to p2p_register_connection_type()?
 *  Thread Starter [Zack Katz](https://wordpress.org/support/users/katzwebdesign/)
 * (@katzwebdesign)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-php-warning-with-wp_debug-on/#post-2783955)
 * I used `'fields' => 'all'`, but now I realize I didn’t understand what the `fields`
   argument did! Just found [this doc](https://github.com/scribu/wp-posts-to-posts/wiki/Connection-information).
 * Thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Posts 2 Posts] PHP Warning with WP_DEBUG On’ is closed to new
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Zack Katz](https://wordpress.org/support/users/katzwebdesign/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-php-warning-with-wp_debug-on/#post-2783955)
 * Status: resolved