• if (!count($category_posts)) {
    $cat_counts = $wpdb->get_results(” SELECT cat_ID,
    COUNT($tablepost2cat.post_id) AS cat_count
    FROM $tablecategories
    INNER JOIN $tablepost2cat ON (cat_ID = category_id)
    INNER JOIN $tableposts ON (ID = post_id)
    WHERE post_status = ‘publish’ $exclusions
    GROUP BY category_id”);
    foreach ($cat_counts as $cat_count) {
    if (1 != intval($hide_empty) || $cat_count > 0) {
    $category_posts[“$cat_count->cat_ID”] = $cat_count->cat_count;
    }
    }
    }
    when displaying categories it errors out with this error
    Warning: Invalid argument supplied for foreach() in /home2/kemical/public_html/wp-includes/template-functions-category.php on line 304

Viewing 3 replies - 1 through 3 (of 3 total)
  • It’s only a warning, and it means that there are no elements for the foreach loop to run through. I think it can be safely ignored.

    Thread Starter Anonymous

    but then no categories are displayed

    I’m also getting this error. I have just upgraded from WP 1.02 -> 1.2. I am calling the category display function using the call in WP 1.2 index.php file:
    <?php wp_list_cats(); ?>
    I have used phpmyadmin to examine the wp_categories table and it looks fine. I’ve tried creating new categories, and that works fine, but the error persists. I have about 10 categories.
    PHP 4.36, MySQL 4.x, FreeBSD
    Could this be a problem with MySQL 4.x and maybe not in MySQL 3.x?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘category error FOR EACH’ is closed to new replies.