[wp-trac] [WordPress Trac] #41373: Wordpress 4.8 and WPML returns NULL on retrieve of translated slugname. Only ID works

WordPress Trac noreply at wordpress.org
Sat Sep 2 13:22:54 UTC 2017


#41373: Wordpress 4.8 and WPML returns NULL on retrieve of translated slugname.
Only ID works
-------------------------------------------------+-------------------------
 Reporter:  BackuPs                              |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Taxonomy                             |  Review
 Severity:  normal                               |     Version:  4.8
 Keywords:  needs-testing needs-unit-tests       |  Resolution:
  reporter-feedback                              |     Focuses:
-------------------------------------------------+-------------------------

Comment (by BackuPs):

 Replying to [comment:10 SergeyBiryukov]:
 > > Which return false. Which mean ID is not converted and results are
 same in both languages."

 No get_term_by() is returning only false or NULL when a slugname is called
 set to the original language value in the translated page. In the original
 page (default language) it is returning the correct ID for the slugname
 used and one can retrieve all required info for that category.

 Let me explain again.

 Suppose i have a category called 'gallery' and translated into 'galleria'
 for italian....

 if i call get_term_by( 'slug', 'gallery', 'category' ); in both pages (the
 original language page and the translated language page).

 I get in the original language page the ID for the slugname 'gallery' and
 in the translated page i get NULL/false returned !

 But in wp 4.75 we got the ID for 'galleria' although we were calling
 'gallery'. It could be that there was a filter active from wpml to do that
 trick that i do not know. I doubt it though as it was working in other
 language plugins as well.

 So in 4.80 and above we get NULL/false returned only in the translated
 pages and because of that we are not able to retrieve the translated
 category ID or any other information (posts attached to the category).

 In wp 4.8 one has to actually call get_term_by( 'slug', 'galleria',
 'category' ) in the translated page.

 Now that is stupid as now one has to physically create a translated page
 and alter its content in order to get the correct information.

 In 4.7.5 or below one could use just one page, create a translated copy
 and without editing anything one was able to present the correct overview
 of attached translated posts for each language.

 In wp 3.8.x they are all just empty.

 WP is creating the issue here because of its changes. The fix WPML
 presented is restoring the old get_term_by function. You can find more
 details in the link i supplied to you pointing to the issue on the wpml
 support forum.

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


More information about the wp-trac mailing list