WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#126 closed defect (bug) (invalid)

the_category produces Database SQL error and a warning

Reported by: mark Owned by: matt
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:1 mark9 years ago

Call the_category with or without parameters.

comment:2 mark9 years ago

Hrm, posted as major when realized it is actually a crash. Please adjust type.

comment:3 anonymousbugger9 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

comment:4 mark9 years ago

the_category() is being called to pull categories that are assign to a certain post. It worked in 1.2-mingus but has not worked since.

comment:5 matt8 years ago

  • Owner changed from anonymous to matt
  • Resolution changed from 10 to 70
  • Status changed from new to closed

The problem is with the plugin using the functions incorrectly, not with WP.

Note: See TracTickets for help on using tickets.