WordPress.org

Ready to get started?Download WordPress

Forums

category error FOR EACH (4 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    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

  2. carthik
    Member
    Posted 10 years ago #

    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.

  3. Anonymous
    Unregistered
    Posted 10 years ago #

    but then no categories are displayed

  4. fredb86
    Member
    Posted 10 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.