This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 1.05 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Bigul 1 year ago.

Assigned support staff: Bigul.

Author Posts
September 12, 2018 at 12:49 pm

vincentC-20

I am trying to: Create a Query to fetch posts from a custom post type (non-translatable) using terms from a taxonomy (translated) in both languages (the original and translated terms)

Link to a page where the issue can be seen: hidden link

I expected to see: Results

Instead, I got: No results, it seems like WPML is stripping the french term from the query.

I've done a var_dump on my WP_Query:
WP_Query Object
(
[query] => Array
(
[suppress_filters] => 1
[post_type] => innovation
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => condition
[field] => term_id
[terms] => Array
(
[0] => 147
[1] => 16
)

)

)

[s] =>
)

[query_vars] => Array
(
[suppress_filters] => 1
[post_type] => innovation
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => condition
[field] => term_id
[terms] => Array
(
[0] => 147
[1] => 16
)

)

)

[s] =>
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
=>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[meta_query] => Array
(
)

[ignore_sticky_posts] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[posts_per_page] => 10
[nopaging] =>
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => condition
[term_id] => 147
[order] => DESC
)

[tax_query] => WP_Tax_Query Object
(
[queries] => Array
(
[0] => Array
(
[taxonomy] => condition
[terms] => Array
(
[0] => 147
[1] => 16
)

[field] => term_id
[operator] => IN
[include_children] => 1
)

)

[relation] => AND
[table_aliases:protected] => Array
(
[0] => wp_term_relationships
)

[queried_terms] => Array
(
[condition] => Array
(
[terms] => Array
(
[0] => 147
[1] => 16
)

[field] => term_id
)

)

[primary_table] => wp_posts
[primary_id_column] => ID
)

[meta_query] => WP_Meta_Query Object
(
[queries] => Array
(
)

[relation] =>
[meta_table] =>
[meta_id_column] =>
[primary_table] =>
[primary_id_column] =>
[table_aliases:protected] => Array
(
)

[clauses:protected] => Array
(
)

[has_or_relation:protected] =>
)

[date_query] =>
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND (
wp_term_relationships.term_taxonomy_id IN (147)
) AND wp_posts.post_type = 'innovation' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
[posts] => Array
(
)

[post_count] => 0
[current_post] => -1
[in_the_loop] =>
[comment_count] => 0
[current_comment] => -1
[found_posts] => 0
[max_num_pages] => 0
[max_num_comment_pages] => 0
[is_single] =>
[is_preview] =>
[is_page] =>
[is_archive] => 1
[is_date] =>
[is_year] =>
[is_month] =>
[is_day] =>
[is_time] =>
[is_author] =>
[is_category] =>
[is_tag] =>
[is_tax] => 1
[is_search] => 1
[is_feed] =>
[is_comment_feed] =>
[is_trackback] =>
[is_home] =>
[is_404] =>
[is_embed] =>
[is_paged] =>
[is_admin] =>
[is_attachment] =>
[is_singular] =>
[is_robots] =>
[is_posts_page] =>
[is_post_type_archive] => 1
[query_vars_hash:WP_Query:private] => 07ddf657b5165255b9df601e13bc0e15
[query_vars_changed:WP_Query:private] => 1
[thumbnails_cached] =>
[stopwords:WP_Query:private] =>
[compat_fields:WP_Query:private] => Array
(
[0] => query_vars_hash
[1] => query_vars_changed
)

[compat_methods:WP_Query:private] => Array
(
[0] => init_query_flags
[1] => parse_tax_query
)

)

September 14, 2018 at 6:20 am #2734035

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve these issues.

We have released a new version of WPML(4.0.7). Please upgrade to the latest version of WPML after a site backup and make sure the issue is existing or not.

I am enabling the private option for the next reply. Please share with me the code you are using for the Query for a better understanding.

--
Thanks!

Bigul

September 14, 2018 at 5:42 pm #2736338

vincentC-20

These are the arguments I am passing to the WP_Query constructor:
Array
(
[suppress_filters] => 1
[post_type] => innovation
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => condition
[field] => term_id
[terms] => Array
(
[0] => 161
[1] => 24
)

)

)

[s] =>
)

Term 161 is the english translated version of term 24 which is the original french version.

September 17, 2018 at 5:48 am #2739696

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the updates. Please try with the following code and make sure you are getting the expected result or not.

Array
(
[suppress_filters] => false
[post_type] => innovation
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => condition
[field] => term_id
[terms] => Array
(
[0] => 24
)

)

)

[s] =>
)

If you are still having the issue, please let me know in which page you are calling this query for a better understanding.

--
Thanks!

Bigul

September 18, 2018 at 1:15 pm #2745211

vincentC-20

Changed the query, results didn't change:

$args:
Array
(
    [suppress_filters] => 
    [post_type] => innovation
    [tax_query] => Array
        (
            [0] => Array
                (
                    [taxonomy] => condition
                    [field] => term_id
                    [terms] => Array
                        (
                            [0] => 16
                        )

                )

        )

    [s] => 
)

new WP_Query($args):
WP_Query Object
(
    [query] => Array
        (
            [suppress_filters] => 
            [post_type] => innovation
            [tax_query] => Array
                (
                    [0] => Array
                        (
                            [taxonomy] => condition
                            [field] => term_id
                            [terms] => Array
                                (
                                    [0] => 147
                                )

                        )

                )

            [s] => 
        )

    [query_vars] => Array
        (
            [suppress_filters] => 1
            [post_type] => innovation
            [tax_query] => Array
                (
                    [0] => Array
                        (
                            [taxonomy] => condition
                            [field] => term_id
                            [terms] => Array
                                (
                                    [0] => 147
                                )

                        )

                )

            [s] => 
            [error] => 
            [m] => 
            [p] => 0
            [post_parent] => 
            [subpost] => 
            [subpost_id] => 
            [attachment] => 
            [attachment_id] => 0
            [name] => 
            [static] => 
            [pagename] => 
            [page_id] => 0
            [second] => 
            [minute] => 
            [hour] => 
            [day] => 0
            [monthnum] => 0
            [year] => 0
            [w] => 0
            [category_name] => 
            [tag] => 
            [cat] => 
            [tag_id] => 
            [author] => 
            [author_name] => 
            [feed] => 
            [tb] => 
            [paged] => 0
            [meta_key] => 
            [meta_value] => 
            [preview] => 
            [sentence] => 
            [title] => 
            [fields] => 
            [menu_order] => 
             => 
            [category__in] => Array
                (
                )

            [category__not_in] => Array
                (
                )

            [category__and] => Array
                (
                )

            [post__in] => Array
                (
                )

            [post__not_in] => Array
                (
                )

            [post_name__in] => Array
                (
                )

            [tag__in] => Array
                (
                )

            [tag__not_in] => Array
                (
                )

            [tag__and] => Array
                (
                )

            [tag_slug__in] => Array
                (
                )

            [tag_slug__and] => Array
                (
                )

            [post_parent__in] => Array
                (
                )

            [post_parent__not_in] => Array
                (
                )

            [author__in] => Array
                (
                )

            [author__not_in] => Array
                (
                )

            [meta_query] => Array
                (
                )

            [ignore_sticky_posts] => 
            [cache_results] => 1
            [update_post_term_cache] => 1
            [lazy_load_term_meta] => 1
            [update_post_meta_cache] => 1
            [posts_per_page] => 10
            [nopaging] => 
            [comments_per_page] => 50
            [no_found_rows] => 
            [taxonomy] => condition
            [term_id] => 147
            [order] => DESC
        )

    [tax_query] => WP_Tax_Query Object
        (
            [queries] => Array
                (
                    [0] => Array
                        (
                            [taxonomy] => condition
                            [terms] => Array
                                (
                                    [0] => 147
                                )

                            [field] => term_id
                            [operator] => IN
                            [include_children] => 1
                        )

                )

            [relation] => AND
            [table_aliases:protected] => Array
                (
                    [0] => wp_term_relationships
                )

            [queried_terms] => Array
                (
                    [condition] => Array
                        (
                            [terms] => Array
                                (
                                    [0] => 147
                                )

                            [field] => term_id
                        )

                )

            [primary_table] => wp_posts
            [primary_id_column] => ID
        )

    [meta_query] => WP_Meta_Query Object
        (
            [queries] => Array
                (
                )

            [relation] => 
            [meta_table] => 
            [meta_id_column] => 
            [primary_table] => 
            [primary_id_column] => 
            [table_aliases:protected] => Array
                (
                )

            [clauses:protected] => Array
                (
                )

            [has_or_relation:protected] => 
        )

    [date_query] => 
    [request] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1  AND ( 
  wp_term_relationships.term_taxonomy_id IN (147)
) AND wp_posts.post_type = 'innovation' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
    [posts] => Array
        (
        )

    [post_count] => 0
    [current_post] => -1
    [in_the_loop] => 
    [comment_count] => 0
    [current_comment] => -1
    [found_posts] => 0
    [max_num_pages] => 0
    [max_num_comment_pages] => 0
    [is_single] => 
    [is_preview] => 
    [is_page] => 
    [is_archive] => 1
    [is_date] => 
    [is_year] => 
    [is_month] => 
    [is_day] => 
    [is_time] => 
    [is_author] => 
    [is_category] => 
    [is_tag] => 
    [is_tax] => 1
    [is_search] => 1
    [is_feed] => 
    [is_comment_feed] => 
    [is_trackback] => 
    [is_home] => 
    [is_404] => 
    [is_embed] => 
    [is_paged] => 
    [is_admin] => 
    [is_attachment] => 
    [is_singular] => 
    [is_robots] => 
    [is_posts_page] => 
    [is_post_type_archive] => 1
    [query_vars_hash:WP_Query:private] => b80c710ec5c9e29c16765a20da744b2b
    [query_vars_changed:WP_Query:private] => 1
    [thumbnails_cached] => 
    [stopwords:WP_Query:private] => 
    [compat_fields:WP_Query:private] => Array
        (
            [0] => query_vars_hash
            [1] => query_vars_changed
        )

    [compat_methods:WP_Query:private] => Array
        (
            [0] => init_query_flags
            [1] => parse_tax_query
        )

)
September 18, 2018 at 1:20 pm #2745230

vincentC-20

This query is being run inside a widget, that is instanciated inside a page built with Elementor.

September 18, 2018 at 5:23 pm #2746162

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the feedback. I have a couple of requests to track the issue.

a) Please let me know the exact steps to reproduce the issue on your site. It will be great if you can share the URL of the following page.

This query is being run inside a widget, that is instantiated inside a page

b) Please allow me to make a duplicator copy of your site using Duplicator plugin(https://wordpress.org/plugins/duplicator/) for debugging the issue on my local server.

--
Thanks!

Bigul

September 19, 2018 at 1:39 am #2746799

vincentC-20

Steps to reproduce:
1) Login to hidden link
2) Go to hidden link
3) Enter a seach query (Anxiety in this case)
4) Press the search button
5) The resulting query args and WP_Query will be dumped to the page (for admins only, which is why you need to connect in the first place)

I will make a duplicator copy tomorrow.

September 19, 2018 at 1:27 pm #2748950

vincentC-20

I can't mark the reply as private...

September 19, 2018 at 3:02 pm #2749197

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the steps and permission. I can reproduce the issue on site now. I have downloaded the Duplicator copy of your site. Will debug it further and get back to you soon. Please wait.

--
Thanks!

Bigul

September 20, 2018 at 12:21 pm #2752070

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

For your kind updates, I had a few rounds of testing on my local server. It works for me as expected after I duplicate or translate the *Innovations* posts to English. It is an expected result because we have translated the *Conditions* terms to English, but not the *Innovations* Posts.

Normally it will work for the non translated Post Types or Taxonomies if we choose *Translatable - use translation if available or fallback to default language* option as the translation preference for the Post Types or Taxonomies. But in our case *Conditions* terms are translated into English.

Therefore as a workaround please Duplicate the *Innovations* posts to English. You can bulk Duplicate the Posts from WPML>>Translation Management Dashboard after marking *Innovations* Post Type as *Translate*.

Please check it and let me know your feedback.

--
Thanks!

Bigul

September 20, 2018 at 3:43 pm #2752754

vincentC-20

Hello Bigul,

I do not want to translate this post type because I want all the posts to be available in both languages. These posts are created by contributors and we will not necessarily have a translation for each when they are first entered.

If there is really other way to go about this, is there a way to programmatically automate the creation of translations?

Thanks,

September 21, 2018 at 6:06 am #2754070

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the feedback. WPML doesn't have an option to automate the translation of a Post or Page. But you can automatically Duplicate a Post while creating it from the default language(French in our case). We have API called *wpml_admin_make_post_duplicates* for this purpose. By using this hook you can automatically Duplicate the posts. It will also help to get the Posts in both languages.

Please check the following documentation for more details and let me know your feedback.

https://wpml.org/wpml-hook/wpml_admin_make_post_duplicates/

--
Thanks!

Bigul

The topic ‘[Closed] WP_Query stripping other language terms from SQL despite suppress_filters = true’ is closed to new replies.