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 4 replies, has 2 voices.

Last updated by Luca 2 weeks, 2 days ago.

Assigned support staff: Marcos Vinicios Barreto.

Author Posts
October 1, 2019 at 12:09 pm #4671919

Luca

Hello,

i'm losing too many time with this problem, and I need help from you.
I'm developing a website in Italian as first language, and English as second language.

In this website I have multiple Custom Post Type and Custom Taxonomies.
This is an example of what does not work at all:

This should be the correct situation:
- hidden link
- hidden link

- hidden link
- hidden link

But I have problem on translating CPT slug, AND I have this situation:
- hidden link (Slug not correct)

I'm using String Translation with .po file.
I'm including .po file in this way:

add_action( 'after_setup_theme', 'coesum_language_po' );
function coesum_language_po(){
	load_child_theme_textdomain(
		COESUM_LANG_DOMINIO,
		apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', COESUM_LANG_DOMINIO )
	);
}

And I create CPT in this way:

$args = array(
		'labels' => $labels,
		'show_ui' => true,
		'show_in_rest' => true,
		'public' => true,
		'publicly_queryable' => true,
		'query_var' => true,
		'has_archive' => true,
		'hierarchical' => false,
		'show_in_nav_menus ' => true,
		'rewrite' => array('slug' => 'service'),
		'capability_type' => 'post',
		'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'excerpt', 'author', 'page-attributes'),
		'taxonomies' => array('service_category'),
		'menu_icon' => 'dashicons-tickets-alt',
		'menu_position' => 20.1
	);

and Custom Taxonomy in this way:

register_taxonomy(
		'service_category',
		array('coesum_service'),
		array(
			'hierarchical' => true,
			'labels' => $labels,
			'show_ui' => true,
			'query_var' => true,
			'show_in_rest' => true,
			'rewrite' => array('slug' => __('service-category', COESUM_LANG_DOMINIO))
		)
	);

If I translate 'service' putting __( 'service', COESUM_LANG_DOMAIN) I have this situation:
- hidden link (Correct)
- hidden link (Not correct, with error 404)

I try really everything you suggest in your forum, but I have not resolved nothing.

Please help me to understand what I have to do with this.

October 1, 2019 at 7:57 pm #4675143

Marcos Vinicios Barreto
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Bahia (GMT-03:00)

Hello,

Thank you for contacting WPML Support. I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

**IMPORTANT**

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

Please, let me know if you need any additional details. Have a nice day.

October 2, 2019 at 2:08 pm #4681265

Luca

Hello,
after some time I resolved the problem that didn't permit me to save the translation of CPT Slug on WPML >> Settings >> Translate Custom Post Type section.

When I defined my personal CPT on function.php I set the priority on 100.

This is the example I did:

add_action('init', 'register_posttype_service', 100 );

To solve my problem just set 5 on priority:

add_action('init', 'register_posttype_service', 5 );

This is because when WPML tried to save the translation on the DB it didn't find the CPT defined yet.

Hope this info will be useful to anyone meets the same problem.

October 2, 2019 at 2:09 pm #4681271

Luca

My issue is resolved now, I explained before how.
Thank you!