Translate all page links

0.0/5
<?php
add_filter('_get_page_link', 'wpd_translate_page_link', 10, 2);

function wpd_translate_page_link($link, $id) {
	remove_filter('_get_page_link', 'wpd_translate_page_link');
	
	$type = get_post($id)->post_type;
	$translated_id = apply_filters( 'wpml_object_id', $id, $type, true );
	
	$link = _get_page_link($translated_id);
	add_filter('_get_page_link', 'wpd_translate_page_link', 10, 2);
	
	return $link;
}

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

Author

Tags

This snippet is untagged