Translate your WordPress posts, pages, and custom post types with cultural context preservation
Add this code to your theme's functions.php:
// Add CulturalTranslate API integration
add_action('rest_api_init', function () {
register_rest_route('culturaltranslate/v1', '/translate', array(
'methods' => 'POST',
'callback' => 'culturaltranslate_translate_post',
'permission_callback' => function () {
return current_user_can('edit_posts');
}
));
});
function culturaltranslate_translate_post($request) {
$post_id = $request['post_id'];
$target_lang = $request['target_lang'];
$api_key = get_option('culturaltranslate_api_key');
$api_url = 'https://culturaltranslate.com/api/integrations/wordpress/translate';
$response = wp_remote_post($api_url, array(
'headers' => array(
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json'
),
'body' => json_encode(array(
'post_id' => $post_id,
'target_language' => $target_lang,
'site_url' => get_site_url()
))
));
return json_decode(wp_remote_retrieve_body($response));
}
Get your API key from your CulturalTranslate dashboard
In your WordPress admin:
When editing a post or page, you'll see a "Translate" button in the editor. Click it to translate your content!
Translate all your posts and pages automatically
Support for WooCommerce products and custom types
Keep translations in sync when you update content
Optimized for multilingual SEO
Get the official CulturalTranslate plugin for WordPress