WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 6 months ago

#41373 closed defect (bug)

Wordpress 4.8 and WPML returns NULL on retrieve of translated slugname. Only ID works — at Initial Version

Reported by: BackuPs Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: Taxonomy Keywords: needs-testing needs-unit-tests reporter-feedback
Focuses: Cc:

Description

Hi

There are mayor issues with wp 4.8 and wpml, polylang or any other multilanguage plugin.

Since wp 4.8 the shortcode executed in the translated page is not calling the translated category anymore

I have one category for my custom post type "portfolio" called "gallery" the category is translated to "gallerij" for the dutch language. They both have 3 posts attached. Each for their own language.

I have this in my english page. [portfolio category="gallery"] calling the posts from the category gallery and it is showing 3 posts.

The page is duplicated into Dutch but the shortcode is the SAME. So the dutch page also has [portfolio category="gallery"] and NOT [portfolio category="gallerij"]. So the dutch page is calling the English category.

Now in wp 4.7.x this works perfectly and the dutch page shows the dutch portfolio items, or if you use a blog shortcode the blog items for each language.

But the moment wp 4.8 is installed the dutch pages with shortcodes are empty and i need to set the Dutch page with the shortcode to translated independently and change the shortcode manually to [portfolio category="gallerij"] so that it is calling the dutch category called "gallerij"

What changed in the wp code? The theme i am using did not change the theme code. Moreover it happens in any theme i try. The return is NULL when calling a slugname.

I tested this 3 x times now in a clean wp install on my local host and i get similar results all the time.

The moment i revert to wp 4.7 there is no issue. If i activate wp 4.8 the issue occurs and the translated page is empty not showing any portfolio or blog items.

Note : i tested this in my local host and was able to reproduce the same issue over and over again by reverting back and forth to wp 4.7.4 and 4.8.

Note : the categories are synchronized !! There is no issue in using the settings wrong or whatever.

in wp 4.7.x this


<?php
$term_slug='gallery';
$term_data = get_term_by( 'slug', $term_slug, 'category' );
$term_id = (int) $term_data->term_id; 
echo 'term-id :'.$term_id;

returns the id of the translated category in the translated page.

in wp 4.8 and above it returns 0 for that category in the translated page but the correct id in the page with primary original language.

So there are two faillures here.

The get_term_by fails but also the query fails... see previous reply. They both return nothing when wp 4.8 is used. $cat a list of category slugnames in the original default language

<?php
$query['tax_query'] = array(
    array(
        'taxonomy' => 'category',
        'field' => 'slug',
        'terms' => explode(',', $cat)
    )
);
 
$r = new WP_Query($query);

$cat has the slugname(s) selected separated by a ','

I reported this to wpml, https://wpml.org/forums/topic/translated-category/ but further testing learned that it happens in any multilanguage plugin so it must be a wp issue.

As said it does not happen in wp 4.7.x or below.

The solution provided for wpml does not work for me as all users have already generated shortcodes that use the slugnames, but more over these slugnames are used to filter the items by ajax filtering.

its a big problem and serious bug.

Pls provide a fix.

Change History (0)

Note: See TracTickets for help on using tickets.