Hi,
thanks for clarifying.
Currently, there is no built-in way to do this – we plan to add one in the future, though.
For now, you would have to filter the CPT archive links and replace the slug. This could look something like the following:
add_filter( 'mlp_linked_element_link', 'filter_mlp_linked_cpt_archive_link', 10, 4 );
/**
* Returns the given URL after having replaced the CPT slug part wrt. the current language.
*
* @param string $url Current URL.
* @param int $target_site_id Target site ID.
* @param int $target_content_id Target content ID.
* @param Mlp_Translation_Interface $translation Translation object.
*
* @return string
*/
function filter_mlp_linked_cpt_archive_link(
$url,
$target_site_id,
$target_content_id,
Mlp_Translation_Interface $translation
) {
if ( ! is_post_type_archive() ) {
return $url;
}
if ( ! is_a( $translation, 'Mlp_Translation_Interface' ) ) {
return $url;
}
$source_site_id = $translation->get_source_site_id();
if ( ! $source_site_id ) {
return $url;
}
$fragments = array(
// EN
1 => array(
'/book/',
'/pizza/',
),
// FR
2 => array(
'/livre/',
'/crepe/', // ;)
),
);
if ( empty( $fragments[ $source_site_id ] ) ) {
return $url;
}
if ( empty( $fragments[ $target_site_id ] ) ) {
return $url;
}
return str_replace(
$fragments[ $source_site_id ],
$fragments[ $target_site_id ],
$url
);
}
The $fragments
array has the site IDs as keys and the according CPT slugs (i.e., their individual translation in that language) as values.
Hope this helps!
Thorsten