WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#43787 new defect (bug)

sql error in wp_get_post_terms

Reported by: d1sabled Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: close reporter-feedback
Focuses: Cc:

Description

hi guys,

i create new plugin, and when i try to fetch all custom taxonomies of the post, i give an error :

my code:

 [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 'FROM wp_terms AS t  INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id ' at line 1]

SELECT   FROM wp_terms AS t  INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('olympic_games_tax') AND tr.object_id IN (15950) ORDER BY t.name ASC 
<?php
$term_list = wp_get_post_terms(get_the_ID(), 'olympic_games_tax', array("fields" => "slug"));

Have a nice day.

Change History (2)

#1 follow-up: @SergeyBiryukov
2 months ago

  • Component changed from General to Taxonomy
  • Keywords close reporter-feedback added

Hi @d1sabled, welcome to WordPress Trac! Thanks for the report.

slug is not a supported value for the fields argument, try id=>slug instead.

#2 in reply to: ↑ 1 @d1sabled
2 months ago

Hi @SergeyBiryukov ,

Yes, I know, but I don't think it's okay to appear sql error on incorect param.

Replying to SergeyBiryukov:

Hi @d1sabled, welcome to WordPress Trac! Thanks for the report.

slug is not a supported value for the fields argument, try id=>slug instead.

Note: See TracTickets for help on using tickets.