Skip to content

Instantly share code, notes, and snippets.

@DevWael
Last active February 3, 2019 05:06
Show Gist options
  • Save DevWael/eb5537b7b86feeb0c7aad51eba542755 to your computer and use it in GitHub Desktop.
Save DevWael/eb5537b7b86feeb0c7aad51eba542755 to your computer and use it in GitHub Desktop.
Get the translated post id of the given object id (the object id can be a post type or category or tag etc...)(WPML only)
<?php
function prefix_lang_object_ids($object_id, $type) {
if( is_array( $object_id ) ){
$translated_object_ids = array();
foreach ( $object_id as $id ) {
$translated_object_ids[] = apply_filters( 'wpml_object_id', $id, $type, true, $current_language );
}
return $translated_object_ids;
} else {
return apply_filters( 'wpml_object_id', $object_id, $type, true, $current_language );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment