[wp-trac] [WordPress Trac] #14490: function "get cat ID" fails if category name has an apostrophe

WordPress Trac noreply at wordpress.org
Sat Mar 2 14:02:06 UTC 2019


#14490: function "get cat ID" fails if category name has an apostrophe
---------------------------------------------+-------------------------
 Reporter:  iamronen                         |       Owner:  (none)
     Type:  defect (bug)                     |      Status:  closed
 Priority:  normal                           |   Milestone:
Component:  Taxonomy                         |     Version:  3.1
 Severity:  minor                            |  Resolution:  worksforme
 Keywords:  reporter-feedback bulk-reopened  |     Focuses:
---------------------------------------------+-------------------------
Changes (by boonebgorges):

 * keywords:  reporter-feedback, bulk-reopened => reporter-feedback bulk-
     reopened
 * status:  reopened => closed
 * resolution:   => worksforme
 * milestone:  Awaiting Review =>


Comment:

 I'm unable to reproduce most of the issues described in this ticket.

 - A category created as "Foo’Bar" is properly retrieved using `get_cat_ID(
 "Foo’Bar" )`
 - A category created as "Foo'Bar" is properly retrieved using `get_cat_ID(
 "Foo'Bar" )`
 - Both categories can be edited at wp-admin/term.php without changing the
 apostrophe formatting
 - I can confirm that `Foo'Bar` is showing as `Foo’Bar` on edit-tags.php,
 but this is just a formatting issue, and doesn't appear to affect querying
 by `get_cat_ID()`

 One thing I can confirm is that `single_cat_title()` is being run through
 `wptexturize()` (ie, the return characters are HTML-encoded). But
 `single_cat_title()` is meant for display, not for fetching data for the
 purposes of querying. If tutorials around the web say otherwise, then the
 tutorials are incorrect :) `get_queried_object()` is the best way to
 identify the category on a term archive.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/14490#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list