WordPress.org

Ready to get started?Download WordPress

Forums

Warning: Invalid argument supplied for foreach() error (5 posts)

  1. roytheboy
    Member
    Posted 1 year ago #

    Hi there,
    I wonder if anyone can help me?
    I have just migrated a website from one host to another and I am getting this php warning on a couple of website pages which I didn't get on the previous hosting:

    Warning: Invalid argument supplied for foreach() in /data02/c7653568/public_html/wordpress/wp-content/themes/playforce/sidebar.php on line 16

    Example of error is here, top right:
    http://www.playforce.co.uk/products/playforce-shop/

    The version of php used in the new webspace is 5.3.26.

    Any help greatly appreciated!!

    Roytheboy.

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    what code is in line 16 of sidebar.php of your theme?

    possibly post the full code of sidebar.php into a pastebin - see http://codex.wordpress.org/Forum_Welcome#Posting_Code

  3. roytheboy
    Member
    Posted 1 year ago #

    Hi alchymyth,
    thanks for the reply-
    line 16 code is:

    foreach( $tac_ids as $id => $on )

    sidebar.php code below:

    http://pastebin.com/fKte4A3D

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    if the custom field "tacticals" is not set for any reasons, you'll get the warning;

    try and change line 16 to:

    if( $tac_ids ) foreach( $tac_ids as $id => $on )
  5. roytheboy
    Member
    Posted 1 year ago #

    Wow!
    alchymyth I can't thank you enough!!
    That seems to have done the trick!
    For some reason I thought it might be the plugins or the previous hosting company might have supressed the Php error reporting in their .ini.

    Thanks for your time and expertise!

Topic Closed

This topic has been closed to new replies.

About this Topic