• I’m having errors on my footer. The footer.php looks like this through line 4. The error says it’s on line 4 which is the foreach line. Any ideas. I’m not a php guy, as you can tell.

    <?php sr_sidebar(‘right’) ?>
    <?php
    global $options;
    foreach ($options as $value) {
    if (get_option( $value[‘id’] ) === FALSE) { $$value[‘id’] = $value[‘std’]; }
    else { $$value[‘id’] = get_option( $value[‘id’] ); }
    }
    ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • What theme are you using? What is the exact error message you’re receiving?

    Thread Starter eladconsulting

    (@eladconsulting)

    Warning: Invalid argument supplied for foreach() in /home/content/hosting/html/janetteam/wp-content/themes/Simple_Realty_1_5_1_rm2/footer.php on line 4

    What is the output of var_dump( $options )? I can’t find your theme in the official WP.org repository; have you spoken to your theme’s vendors?

    Thread Starter eladconsulting

    (@eladconsulting)

    The theme hasn’t been supported for a while now.

    I’m not sure what you mean by output of var_dump( $options )

    You get this error if you pass a variable that isn’t an array to foreach(). Without knowing how your theme is coded, it’s going to be very difficult to figure out where the error is coming from, though.

    Add var_dump( $options ); to your footer code temporarily, and then post the output, so I can see what type of variable $options is:

    <?php sr_sidebar('right') ?>
    <?php
    global $options;
    var_dump( $options );
    foreach ($options as $value) {
    if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; }
    else { $$value['id'] = get_option( $value['id'] ); }
    }
    ?>
    Thread Starter eladconsulting

    (@eladconsulting)

    NULL

    So $options isn’t even being set. I’m sorry, but without being able to see your theme’s code, I’m not sure where to proceed from here. You might want to consider posting at https://jobs.wordpress.net/ for more personalized help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘foreach() errors’ is closed to new replies.