This thread is resolved. Here is a description of the problem and solution.

Problem: The client wants to show the same content from his original language at his translated language.

Solution: With the WPML version 3.9, we have created a new type of translation, which will help you to show the original posts in the translated language without creating new posts in the translated language, you can read more about this feature here: https://wpml.org/2017/11/wpml-3-9-beta-makes-content-duplication-a-thing-of-the-past/

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.

This topic contains 5 replies, has 2 voices.

Last updated by Tim 2 years, 6 months ago.

Assigned support staff: Ahmed Ibrahim.

Author Posts
December 6, 2017 at 11:36 pm #1451299

Tim

I am trying to: get a list of custom post type items.

Link to a page where the issue can be seen:
English: hidden link runs fine.
Japanese: hidden link does not show list of publications. This was working. The publications that it should display are in English.

I expected to see: a list of publications under the words Selected Resources (see English page)

Instead, I got: nothing below those words. I looked at the WP_Query Object and the SQL that is generated on the Japanese page does not take the taxonomy query into account. Even worse it creates a SQL statement that can never return any results:
English SQL:

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) 
INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )  
INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id )  
INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) 
SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )  INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id )  INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) WHERE 1=1  AND ( 
  ( 
    0 = 1
  )
) AND ( 
  ( wp_postmeta.meta_key = 'rating' AND wp_postmeta.meta_value IN ('1') ) 
  AND 
  mt1.meta_key = 'publication_date' 
  AND 
  ( 
    ( mt2.meta_key = 'year' AND mt2.meta_value >= '2015' ) 
    OR 
    ( mt2.meta_key = 'isfavourite' AND CAST(mt2.meta_value AS SIGNED) > '0' )
  )
) AND wp_posts.post_type = 'publications' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future')) GROUP BY wp_posts.ID ORDER BY CAST(wp_postmeta.meta_value AS CHAR) ASC, CAST(mt1.meta_value AS DATE) DESC, wp_posts.post_title ASC LIMIT 0, 35WHERE 1=1  AND ( 
  ( 
    wp_term_relationships.term_taxonomy_id IN (274)
  )
) AND ( 
  ( wp_postmeta.meta_key = 'rating' AND wp_postmeta.meta_value IN ('1') ) 
  AND 
  mt1.meta_key = 'publication_date' 
  AND 
  ( 
    ( mt2.meta_key = 'year' AND mt2.meta_value >= '2015' ) 
    OR 
    ( mt2.meta_key = 'isfavourite' AND CAST(mt2.meta_value AS SIGNED) > '0' )
  )
) AND wp_posts.post_type = 'publications' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future')) GROUP BY wp_posts.ID ORDER BY CAST(wp_postmeta.meta_value AS CHAR) ASC, CAST(mt1.meta_value AS DATE) DESC, wp_posts.post_title ASC LIMIT 0, 35

Japanese SQL (same page template, same args to WP_Query():

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID 
FROM wp_posts  
INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )  
INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id )  
INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) 
WHERE 1=1  AND ( 
  ( 
    0 = 1
  )
) AND ( 
  ( wp_postmeta.meta_key = 'rating' AND wp_postmeta.meta_value IN ('1') ) 
  AND 
  mt1.meta_key = 'publication_date' 
  AND 
  ( 
    ( mt2.meta_key = 'year' AND mt2.meta_value >= '2015' ) 
    OR 
    ( mt2.meta_key = 'isfavourite' AND CAST(mt2.meta_value AS SIGNED) > '0' )
  )
) AND wp_posts.post_type = 'publications' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future')) GROUP BY wp_posts.ID ORDER BY CAST(wp_postmeta.meta_value AS CHAR) ASC, CAST(mt1.meta_value AS DATE) DESC, wp_posts.post_title ASC LIMIT 0, 35

I downgraded my version of WordPress to 4.8.3 and when I ran the Japanese page with that WP version then the Japanese SQL generated matched the English SQL generated and I got the same 35 publications on both pages.

December 8, 2017 at 1:30 pm #1452874

Ahmed Ibrahim
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi, and thanks for contacting our support forum.

So I just need to be clear about some point, first, you mentioned "This was working. The publications that it should display are in English", you also mentioned that with version WordPress to 4.8.3 you got the same 35 publications on both pages, so should the Japanese page also show the English "publications"?

To be able to debug the problem I’d like to replicate your site locally. so could you please point me where I can find this query in your code, and also please temporarily install a plugin called "Duplicator" on your site. This will allow you to create a copy of your site and your content. You can provide me with the snapshot following these directions:
If you already know how Duplicator works ( http://wordpress.org/plugins/duplicator/ ), please skip the following steps and just send me the installer file and the zipped package you downloaded.

:: Duplicator instructions
. From WordPress plugin page, look for "Duplicator" and install it
. Once installed, you get a new main menu "Duplicator"
. Chose "Packages"
. Click on the first button you find in the toolbar on the right ("Create Package")
. Give it a name or leave it as is
. Click on "Create Package Set"
. Wait until the package is ready
. Click on "Installer", then on "Package": the first one is just a PHP script, the second one is a zip file containing everything you need
. Send me both files (you probably want to use DropBox, Google Drive, or similar services)
#Important:
As the snapshot file will be quite big, you can exclude the images if the file is very big, you can use the filters to exclude the uploads file and also use the filter to exclude any compressed files with these extensions .rar, .gz and .zip )

I will set the next reply as a private reply so you will able to provide a link to download the duplicator package.

Thanks and Best Regards

December 11, 2017 at 8:09 pm #1454822

Ahmed Ibrahim
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi, and thanks for the package.

I have investigated your site and found that you haven't marked the post type "Publications" to be translatable, so it is normal that you don't found posts in the translated language, so with your current WPML version the steps to resolve this will be to go to WPML -> Translation Management -> Multilingual Content Setup -> Custom Posts, and then to mark the custom post to be translatable, then to go to your original posts and then to duplicate or Translate, but with the new version WPML 3.9, we have created a new type of translation, which will help you to show the original posts in the transled language without creating new posts in the translated language, you can read more about this feature here: https://wpml.org/2017/11/wpml-3-9-beta-makes-content-duplication-a-thing-of-the-past/
For now, the 3.9 full version hasn't been released yet, and I don't have the exact release date, but it should be very soon, and for now, you can test the beta version if you have a test site, you can find it here: https://wpml.org/account/downloads/.

Please let me know if that helps you.
Best Regards.

December 11, 2017 at 8:39 pm #1454850

Tim

Hello,
Thank you for investigating.

The page worked the way we wanted it to before WP 4.9. The publications post_type was not translateable then.

We have no plans to translate the 2000+ members of the publications post type, we want the English language posts to appear in the list on the Japanese page, which is how this worked before WP 4.9. We liked that it worked that way.

In the past, the English language posts appeared on the Japanese page. In WP 4.9, this stopped working.

Is it that in the past the page was not working as expected?

Thanks

December 12, 2017 at 3:33 pm #1455780

Ahmed Ibrahim
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

The correct way is that when you don't select a post type to be translatable, it will not show anything at the secondary language. As I mentioned in my previous reply, with the new WPML 3.9 it is not necessary to translate the content if you want to show the same posts at the two languages, so, please wait for that version it should be released very soon.

Best Regards.

December 18, 2017 at 10:02 pm #1460861

Tim

I created a work around. Your suggestion did not help.