WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Calling wp_list_categories twice gives MySQL error (4 posts)

  1. khamega
    Member
    Posted 7 years ago #

    I'm trying to call the wp_list_categories function twice but this gives me a MySQL error.

    My reason for wanting to do this is I want to list the contents of 2 parent categories seperately without including the parent category in the list.

    I'm using the following code I get the error.

    <li>
    <h2>Browse By Location</h2>
    <ul><?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=1&title_li='); ?></ul>
    </li>
    
    <li>
    <h2>Browse By Rating</h2>
    <ul><?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=8&title_li='); ?></ul>
    </li>

    However, if I just call the function once I don't get the error.

    When try to call the funtion twice I get one category list being displayed and the other I get the following error.

    Warning: join() [function.join]: Bad arguments. in /home/saigonho/public_html/wp-includes/category.php on line 290

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND post_type = 'post' AND post_status = 'publish'' at line 1]
    SELECT post_id, category_id FROM wp_post2cat LEFT JOIN wp_posts ON post_id = ID WHERE category_id IN () AND post_type = 'post' AND post_status = 'publish'

    Warning: Invalid argument supplied for foreach() in /home/saigonho/public_html/wp-includes/category.php on line 300

    I'm also running PHP 4.4.6 and MySQL 4.1.21 if that helps.

    Any advice would be greatly appreciated.

    Kham

  2. MichaelH
    Member
    Posted 7 years ago #

    Is it possible you have no categories that meet the condition of the 2nd wp_list_categories, namely a child_of category 8?

  3. khamega
    Member
    Posted 7 years ago #

    I cant' believe after all that I missed such a small thing!

    It's all good now.

    Thanks heaps :)

  4. MichaelH
    Member
    Posted 7 years ago #

    I'd still call that a bug, but glad it is fixed for you.

Topic Closed

This topic has been closed to new replies.

About this Topic