FOREACH Invalid argument supplied
-
Have made a snippet.
add_shortcode('product_qty', function () { $out = ' Цена указана за 1 килограмм.'; $slugs = array("oil-essential"); global $product; static $cats; $cats = get_the_terms($product->id,'product_cat'); $product_in_category = false; foreach ($cats as $key => $cat) { if (in_array($cat->slug, $slugs)) { $product_in_category = true; break; } } if ($product_in_category) { $out = $out . ' Купить можно от 100 грамм.'; } return $out; });
Looks fine. But only on the Main page it shows an error messege:
– Warning: Invalid argument supplied for foreach() in /var/www/chb73f2d7f/www/essenti.com.ua/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()’d code on line 12What can I do to get rid of this?
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘FOREACH Invalid argument supplied’ is closed to new replies.