Opened 9 years ago
Closed 8 years ago
#126 closed defect (bug) (invalid)
the_category produces Database SQL error and a warning
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Template | Version: | |
| Severity: | major | Keywords: | |
| Cc: | mark |
Description
The below error is reached when calling the_category with or without any paremeters. It is not called inside the loop, but is called from with a plugin for WordPress called breadcrumb:
Database error: [You have an error in your SQL syntax near at line 9]
SELECT category_id, cat_name, category_nicename, category_description, category_parent FROM wp_newscategories, wp_newspost2cat WHERE wp_newspost2cat.category_id = cat_ID AND wp_newspost2cat.post_id =
Warning: Invalid argument supplied for foreach() in /mnt/web_g/d24/s42/b01e1b28/www/wordpress/wp-includes/template-functions-category.php on line 139
Change History (5)
comment:2
mark
— 9 years ago
Hrm, posted as major when realized it is actually a crash. Please adjust type.
comment:3
anonymousbugger
— 9 years ago
the_category() calls get_the_category() which is where you are seeing the error.
If you don't call get_the_category() within the loop then you have to supply a non-zero post id. Unfortunately the_category() does not have the ability to call it with one (nor do any of the other calls). It might work if the global $post is still hanging around and vaid when it gets to your call, but that's hardly reliable! Plus if it's a breadcrumb, it sounds like it is probably being called before the loop.
It sounds like some new functionality is required which may or may not make use of get_the_category() with a passed in parameter. What is it you are trying to retrieve?
-- Mike Little
edited on: 06-29-04 10:11
Call the_category with or without parameters.