WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields Shortcodes
Shows warning on "New Post" page (7 posts)

  1. prativasic
    Member
    Posted 2 years ago #

    Current version (0.9) of this plugin shows the following error in new post page in wp admin panel (wp-admin/post-new.php).

    Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/bangla-book/wp-content/plugins/custom-fields-shortcodes/custom-fields-shortcodes.php on line 251

    Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/bangla-book/wp-content/plugins/custom-fields-shortcodes/custom-fields-shortcodes.php on line 273

    However, the plugin works flawlessly till now. And, for reference, this plugin doesn't work with "Custom Field Suite" plugin which is claiming as a fork of "Advanced Custom Fields" plugin. But, as expected, it works with "Advanced Custom Fields" plugin.

    I am actually using it with "Just Custom Fields" plugin, and I am happy with the result.

    Thanks a lot to the developers of such a nice plugin. :)

    http://wordpress.org/extend/plugins/custom-fields-shortcodes/

  2. tlkativ
    Member
    Posted 2 years ago #

    I am getting the same error but the plug-in still seems to be working just fine otherwise. Any thoughts on how to fix the code to get rid of the errors?

  3. prativasic
    Member
    Posted 2 years ago #

    Yes, the plug-in is working pretty fine. But its just annoying.
    No, I didn't get any way to fix this. If yon can, please let me know.

  4. William Rettmann
    Member
    Posted 1 year ago #

    I fixed this problem by typecasting the array in the foreach statement. You can do this by placing (array) in front of the variable on the lines mentioned in the error.

    foreach (<strong>(array)</strong>$groups as $group_id => $group) {
    ...
    }
  5. Curtis4
    Member
    Posted 1 year ago #

    Thank you, William, for saving my Sunday morning.

  6. whateverfree2
    Member
    Posted 1 year ago #

    ok
    line 251 should be:

    foreach ((array)$field['dropdowns'] as $dropdown) {

    and line 273

    foreach ((array)$groups as $group_id => $group) {

    Thanks William

  7. marcobarra
    Member
    Posted 1 year ago #

    this fix worked for me! thanks william!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic