invalid argument for each()


I am having a bug on this page:

Warning: Invalid argument supplied for foreach() in /home/content/04/9655804/html/wp-content/themes/parallelus-salutation/functions.php on line 271

The code in the area is:

function qa_widget_show_sub_cats( $cat_args, $instance ) {

global $post;

if ( is_qa_page() ) {

$cats = get_the_terms( $post->ID, ‘question_category’ );

foreach ( $cats as $category ) {

if ( $category->term_id ) {

$termchildren = get_term_children( $category->term_id, ‘question_category’ );

if ( $termchildren && !empty( $termchildren ) && !is_object( $termchildren ) ) {

$cat_args = $category->term_id;






return $cat_args;


Please help me solve it asap.

Thanks a lot.

  • aecnu
    • WP Unicorn

    Greetings jamy,

    Thank you for this great question and a significant item to bring up.

    I am sorry to report that at this time we do not support Salutations:

    You can even see the theme developer himself commented that there are problems with the theme, that the theme is not of normal construct, and that he is working on a new release with these types of items addressed.

    In addition, the theme developer says within that post that he will support those using it and our plugins.

    For WPMU Dev to not support a specific theme is an unprecedented event, however this theme has been a problem child to the extreme.

    Sorry that I cannot be of further assistance until the theme issues have indeed been addressed by the theme creator.

    Thank you for being a WPMU Dev Community Member!

    Cheers, Joe

  • jamy
    • Flash Drive


    Managed to solve the issue with the help of the WordPress community. I had to add code as follows:

    $cats = get_the_terms( $post->ID, 'question_category' );
    if( $cats ) foreach ( $cats as $category ) {

    This happened when there was no $cats found. I had to add a conditional check as given above.

    About the salutations theme not being supported, that’s kind of bad, but can’t blame the WPMU team as the author itself has mentioned the faults about the theme.

    God Bless us all.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.