• Resolved jbjaaz

    (@jbjaaz)


    The following error appears in the sidebar where the list of categories should be.

    Warning: Invalid argument supplied for foreach() in /www/location/news/wp-includes/template-functions-category.php on line 309

    I think the problem started after upgrading to version 1.5.1.3

    In the php, the code is simply

    list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0,'','','','','')

    Any ideas how to fix this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter jbjaaz

    (@jbjaaz)

    anybody??? I have no idea why this is happening.

    I just upgraded to the latest version and still get the same error.

    Thread Starter jbjaaz

    (@jbjaaz)

    okay I just noticed “wp_get_archives” doesn’t actually print out the archive list either.

    What could be wrong with my installation?

    Moderator James Huff

    (@macmanx)

    Try replacing that line in your sidebar with:

    <?php wp_list_cats('sort_column=name'); ?>

    It’s hard to tell without seeing your site, but you may need to surround it with ul tags, like such:

    <ul>
    <?php wp_list_cats('sort_column=name'); ?>
    </ul>

    But, try the line without the ul tags first.

    Moderator James Huff

    (@macmanx)

    What could be wrong with my installation?

    It’s [very] hard to tell without seeing your site.

    Thread Starter jbjaaz

    (@jbjaaz)

    whoops, sorry for the late response.

    I added ‘sort_column=name’ but I still get the error.

    The site is, https://communitydevelopmentsc.org/news/

    Thread Starter jbjaaz

    (@jbjaaz)

    here’s the relevant php code;

    <h2>Categories</h2>
    <ul>
    <?php wp_list_cats('sort_column=name'); ?>
    </ul>

    <h2>Archives</h2>
    <ul class="last">
    <?php wp_get_archives('type=monthly'); ?>
    </ul>

    Thread Starter jbjaaz

    (@jbjaaz)

    I’m at a loss. Anybody!

    if I run “echo $wpdb->print_error();” I get the following

    WordPress database error: []
    SELECT cat_ID, cat_name, category_nicename, category_description, category_parent FROM wp_categories WHERE cat_ID > 0 ORDER BY cat_name asc

    Which is weird because all posts print out correctly. I would think that means the database is accessible.

    Thread Starter jbjaaz

    (@jbjaaz)

    Okay, I seem to have “solved” the issue.

    I had one user/pass setup for all databases on my server.

    I added a new user/pass strictly for wordpress and the error went away, categories printed out and archives list printed out.

    Now, I was doing the single user/pass for all databases just to make it easier to remember. Is it best practice to use a different user/pass for every database? Why did having a single user/pass cause problems for wordpress. I mean posts printed out fine. Why were the categories and archives list any different?

    Thanks for listening.

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