> For the complete documentation index, see [llms.txt](https://developers.weglot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.weglot.com/wordpress/use-cases/implementing-custom-link-translation.md).

# Implementing Custom Link Translation

By default, Weglot translates links based on built-in patterns. In some cases you may want to build a translated link yourself. Below is an example that returns the URL of a WooCommerce product in the current language. You can adapt it further — for instance to target a specific language instead of the current one.

```php
function weglot_get_current_full_product_by_id( $product_id ) {
	$post = get_post( $product_id );
	if ( ! $post || $post->post_type !== 'product' ) {
		return '';
	}
	$product_url = get_permalink( $product_id );
	return weglot_create_url_object( $product_url )->getForLanguage( weglot_get_request_url_service()->get_current_language() );
}
echo weglot_get_current_full_product_by_id( 17 );
```
