🌍 WordPress Multilingual Site Building an Automatic Translation System with deep L ai and Polylang Lecture

hello! 😊 Today we’re going to learn how to build a system to automatically translate existing and new posts on your WordPress site, and even optimize them for SEO.

in this lesson, we’ll utilize the DeepL API, the Polylang plugin, and Yoast SEOto create an environment that you can set up once and have translations happen automatically. 🚀

as a reminder, the DEEP L API is free to use for translating up to 500,000 characters per month.

📌 Course Objectives

1️⃣ translate all existing Korean posts into English and Japanese
2️⃣ Automatically translate future posts as they are created
3️⃣ preserve the HTML structure of translated posts so that they don’t break
4️⃣ apply SEO (search engine optimization) settings to maximize search visibility
5️⃣ Prevent duplicate translations to avoid retranslating already translated posts

💡 1. Prepare your project

first, you need to prepare your project. it should have the following tasks done

📌 Required installations

WordPress site
polylang plugin (multilingual support)
yoast SEO plugin (search optimization)
deepL API key issued (to use the Translation API)

📌 Get DeepL API key

To use the DeepL translation API, you need an API key.
1️⃣ DeepLGo to the API website
sign up for 2️⃣ and get an API key
3️⃣ Copy your API key( enter it in theYOUR_DEEPL_API_KEY part)

💡 2. Writing the code: Building the automatic translation system

now, let’s build the translation system by adding code to functions.php.

📌 2-1. Code to automatically translate existing posts

first, let’s create code to automatically translate all posts that have already been created.

// function to check if a post is already translated (to avoid duplicate translations) function is_already_translated($post_id, $lang) { $translations = pll_get_post_translations($post_id); return isset($translations[$lang]); // check if a translation exists for that language } // function to translate all existing posts (run only once) function auto_translate_existing_posts() { $languages = [
        'en' => ['prefix' => 'en', 'sep' => '-', 'sitename' => get_bloginfo('name')], 'ja' => ['prefix' => 'ja', 'sep' => '-', 'sitename' => get_bloginfo('name')], ]; $args = [
        'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, ]; $posts = get_posts($args); foreach ($posts as $post) { if (pll_get_post_language($post->ID) !== 'en') continue; foreach ($languages as $lang => $settings) { if (is_already_translated($post->ID, $lang)) { continue; // skip if already translated } $translated_title = deepl_translate_with_html($post->post_title, $lang); $translated_content = deepl_translate_with_html($post->post_content, $lang); $translated_slug = $settings['prefix'] . '-' . sanitize_title($translated_title); $seo_title = $translated_title . ' ' . $settings['sep'] . ' ' . $settings['sitename']; $translated_post_id = wp_insert_post([
                'post_title' => $translated_title, 'post_content' => $translated_content, 'post_status' => 'publish', 'post_type' => $post->post_type, 'post_author' => $post->post_author, 'post_name' => $translated_slug, 'post_category' => wp_get_post_categories($post->ID), 'meta_input' => [
                    '_yoast_wpseo_title' => $seo_title, ], ]); pll_set_post_language($translated_post_id, $lang); pll_save_post_translations([ 'en' => $post->ID, $lang => $translated_post_id, ]);
        } } } // Run translation of existing post (run only once) add_action('admin_init', function () { if (isset($_GET['run_translation']) && $_GET['run_translation'] === '1') { auto_translate_existing_posts(); wp_die('Translation for all existing posts completed.'); } })

🚀 Now, if you run the URL below in your browser, all your existing posts will be translated!

(Make sure to changeyour-site.com to your site domain)

https://your-site.com/wp-admin/?run_translation=1

📌 2-2. New post auto-translation code

Nowset it up so that new posts are automatically translated when they are created.

function auto_translate_and_seo_publish($post_id) { $original_post = get_post($post_id); if ($original_post->post_status !== 'publish') return; $languages = [ 'en' => ['prefix' => 'en', 'sep' => '-', 'sitename' => get_bloginfo('name')], 'ja' => ['prefix' => 'ja', 'sep' => '-', 'sitename' => get_bloginfo('name')], ]; if (pll_get_post_language($post_id) !== 'en') return; foreach ($languages as $lang => $settings) { if (is_already_translated($post_id, $lang)) { continue; // skip if already translated } $translated_title = deepl_translate_with_html($original_post->post_title, $lang);
        $translated_content = deepl_translate_with_html($original_post->post_content, $lang); $translated_slug = $settings['prefix'] . '-' . sanitize_title($translated_title); $seo_title = $translated_title . ' ' . $settings['sep'] . ' ' . $settings['sitename']; $translated_post_id = wp_insert_post([
            'post_title' => $translated_title, 'post_content' => $translated_content, 'post_status' => 'publish', 'post_type' => $original_post->post_type, 'post_author' => $original_post->post_author, 'post_name' => $translated_slug, 'meta_input' => [
                '_yoast_wpseo_title' => $seo_title, ], ]); pll_set_post_language($translated_post_id, $lang); pll_save_post_translations([
            'en' => $post_id, $lang => $translated_post_id, ]); } } // Run automatic translation when a new post is published add_action('publish_post', 'auto_translate_and_seo_publish')

🚀 Final wrap-up

Want to translate all existing posts?

  • run it once: https://your-site.com/wp-admin/?run_translation=1

Want to translate a new post?

  • auto-translated after creating a new post. (No additional work required)

Want to recreate a translated post?

  • delete the existing translated post and run it again.

💡 Now you can run multilingual content in WordPress completely automatically! 🚀 If you have any more questions, feel free to ask! 😊

📌 Additional things to check after the run

  1. check if your translated posts have been created
    • check yourWordPress admin → “All Posts” to see if you have posts translated intoEnglish (EN) andJapanese (JA).
  2. Check the URL
    • korean posts: https://example.co.kr/올림픽-일정/
    • english post: https://example.co.kr/en/olympic-schedule/
    • japanese posts: https://example.co.kr/ja/オリンピック日程/
  3. make sure your translated posts are properly linked in Polylang
    • check translation relationships in yourWordPress admin → Polylang.

📌 Once you finish translating an existing post, you don’t need to run it again

✅ Once you translate an existing post once, you don’t need to run this URL again.
✅ Afterward, when you create a new post, it will be translated automatically.

📌 Additional questions

Q1. Can I run this URL multiple times?

✅ It’s okay to run it multiple times, as it won’t retranslate posts that have already been translated.
✅ Thisis because it contains code(is_already_translated()) that prevents duplicate translations.

Q2. How do I retranslate an existing post?

🚨 You need to delete the existing translation and run it again.
✅ Delete the existing translated post and run https://your-site.com/wp-admin/?run_translation=1 again.

Q3. What if the translation doesn’t happen automatically?

❌ If you run it and it doesn’t translate, check the following

  1. make sure the code is addedto functions.phpcorrectly.
  2. Make sure your DeepL API key is set correctly.
  3. Make sure the Polylang plugin is activated.
  4. wordPress admin → Settings → Save unique address (permalink ) button and run it again.

SEO Tutorial: SEO Master Class for WordPress and AdSense

📢 SEO Lecture in Korea

Search Engine Optimization (SEO) is essential for success online today, especially if you’re running WordPress and AdSense. Learn practical techniques and strategies to increase your traffic from search engines with this customized SEO course. Learn practical techniques and strategies to increase your traffic from search engines!

📌 Course Overview

  1. Lecture Topics:
    • Optimize your WordPress site for SEO
    • SEO strategies for maximizing AdSense revenue
  2. Target:
    • Bloggers and WordPress site operators
    • People who want to increase their AdSense ad revenue
    • Beginners to intermediates who are new to SEO
  3. Lecture Locations:
    • Near Hakdong Station, Gangnam-gu, Seoul (5 minutes walk from Exit 3 of Hakdong Station on Subway Line 7)
    • Convenient online Zoom lectures available
  4. Course Schedule:
    • Time: Every Monday/Wednesday/Friday, 8-9pm
    • Duration: 12 sessions over 4 weeks
  5. Cost of the course:
    • 30,000 won per hour (12 sessions total: 360,000 won)
    • Includes course textbooks and practice materials

📚 Course Curriculum

  1. SEO Basics (1-3):
    • How search engines work
    • How to do keyword research
    • Basic SEO Settings with WordPress Plugins
  2. WordPress SEO Optimization (4~6th time):
    • Yoast SEO, Rank Math plugin in-depth utilization
    • SEO-Friendly Writing and Posting Strategies
    • Optimizing internal and external links
  3. AdSense and SEO (7~9th time):
    • Analyzing and Utilizing High-Paying Keywords
    • Content strategy to increase click-through rate (CTR)
    • How to Optimize Your Google AdSense Ads
  4. SEO Deepening Strategies (10~12th time):
    • Build Backlinks and Utilize Tools
    • Measure your SEO performance (Google Analytics, Google Search Console)
    • Latest SEO trends and algorithm changes

🎓 About the Instructor

KimSEO Instructor:

  • 10 years of experience as a consultant specializing in SEO
  • Experienced in running WordPress and AdSense blogs
  • Expert in teaching Google Analytics (GA) and Search Console utilization

💡 Course Features

  1. Hands-on:
    • Live, hands-on WordPress and AdSense setup during the class.
    • Hands-on lab with direct application to student sites.
  2. Small Personalized Lessons:
    • Small classes limited to a maximum of 10 people per class.
    • Individualized feedback and Q&A sessions available.
  3. Various Support Materials:
    • SEO checklists and guides to utilizing keyword research tools.
    • A post-class recording (if attending online).

📞 Contact Us and Register

  1. 전화: 010-2462-3443
  2. Email: contentflow@contentflow.co.kr

📌 Register Now!

SEO is a must if you want to run WordPress and AdSense successfully. This course will take you from the basics to the practical, so you can make your content stand out in the search engines 🚀

How to Create a Multilingual Website with WordPress

Creating a multilingual (multi-language) website with WordPress can be done in several ways. A multilingual setup allows visitors to view content in their preferred language.

1️⃣ Three Main Methods to Create a Multilingual Website

There are three primary ways to build a multilingual site in WordPress:

MethodDescriptionRecommended For
Using a PluginThe easiest method, with automatic translation support🔹 Quick and easy setup
Using MultisiteEach language operates as a separate site🔹 Full independence for translations
Manual Translation (Subdomain/Subdirectory)Separate pages for each language🔹 Best for SEO and performance

2️⃣ Creating a Multilingual Site with a Plugin (Easiest Method)

💡 Recommended Plugins:
WordPress offers powerful multilingual plugins.

PluginPricingFeatures
WPMLPaidMost powerful multilingual plugin (SEO-friendly)
PolylangFree/PaidLightweight and simple
TranslatePressFree/PaidReal-time front-end translation
WeglotPaidAI-powered automatic translation

🚀 Easiest Option: TranslatePress or Polylang

✅ Method 1: Creating a Multilingual Site with Polylang (Free)

📌 Features:

  • Free version offers powerful functionality
  • Simple to use, with a language switcher
  • Requires manual content translation

📌 Installation & Setup: 1️⃣ Install Polylang Plugin

  • Go to WordPress Admin > Plugins > Add New
  • Search for Polylang, install, and activate

2️⃣ Add Languages

  • Go to Settings > Languages
  • Add languages (e.g., Korean 🇰🇷, English 🇺🇸, Japanese 🇯🇵)

3️⃣ Translate Content

  • Go to Pages > Add New
  • Copy existing pages and manually translate them

4️⃣ Add a Language Switcher

  • Go to Widgets > Add Language Switcher
  • Place it in the menu or sidebar

5️⃣ SEO Optimization

  • Use Yoast SEO or RankMath to optimize multilingual SEO

✅ Method 2: Creating a Multilingual Site with TranslatePress (Free)

📌 Features:

  • Real-time front-end translation
  • AI-powered translation (Google Translate API)
  • Easy to use for beginners

📌 Installation & Setup: 1️⃣ Install TranslatePress Plugin

  • Go to WordPress Admin > Plugins > Add New
  • Search for TranslatePress, install, and activate

2️⃣ Add Languages

  • Go to Settings > TranslatePress
  • Set a default language and add additional languages

3️⃣ Translate Content in Real-Time

  • Click “Translate Site” from the top admin bar
  • Manually translate content on the front-end

4️⃣ Enable Automatic Translation (Optional)

  • Connect to Google Translate API for automatic translation

5️⃣ Add a Language Switcher

  • Go to Settings > Language Switcher
  • Add a switcher to the menu or widget area

✅ Method 3: Creating a Multilingual Site with WPML (Paid)

📌 Features:

  • Most powerful multilingual plugin (recommended for businesses)
  • Supports WooCommerce (multilingual eCommerce)
  • SEO-friendly

📌 Installation & Setup: 1️⃣ Purchase & Install WPML

  • Buy WPML from the official website
  • Install and activate it in WordPress

2️⃣ Add Languages

  • Go to Settings > Languages
  • Configure multilingual settings

3️⃣ Translate Content

  • Use manual translation or the WPML Translation Manager

4️⃣ SEO Optimization

  • Integrate with Yoast SEO or RankMath

3️⃣ Multilingual SEO Optimization (Search Engine Optimization)

SEO is crucial for multilingual websites.

Recommended URL Structure (Best for SEO)

StructureExampleRecommended
Subdirectoryexample.com/en/, example.com/ko/✅ Best SEO practice
Subdomainen.example.com, ko.example.com⚠️ Requires extra domain setup
Separate Domainsexample.kr, example.com✅ Best for independent markets

Adding hreflang Tags
Hreflang tags help search engines identify the correct language for users.

📌 Example Code:

html복사편집<link rel="alternate" hreflang="ko" href="https://example.com/ko/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />

Using SEO Plugins

  • Yoast SEO or RankMath provide multilingual SEO support

4️⃣ Performance Optimization for Multilingual Websites

Multilingual sites can slow down due to multiple translations. Optimize speed using the following:

1️⃣ Caching Plugins → Use LiteSpeed Cache or WP Rocket
2️⃣ Content Delivery Network (CDN) → Use Cloudflare
3️⃣ Image Optimization → Use Smush or ShortPixel
4️⃣ Remove Unnecessary Plugins

5️⃣ Recommended Approaches for Different Use Cases

Recommended MethodDescriptionBest For
PolylangFree, requires manual translation🔹 Personal blogs, small websites
TranslatePressReal-time translation, AI-supported🔹 Easy translation for business sites
WPMLPowerful features, WooCommerce support🔹 Large businesses, eCommerce

👉 Easiest Option: TranslatePress + Google Translate API 🚀

🔥 Final Summary

Easiest Method: Use Polylang or TranslatePress
Need Automatic Translation? Use TranslatePress + Google API
For a Fully Professional Multilingual Site: Use WPML
SEO Optimization is Essential: Add hreflang tags, use SEO plugins
Speed Optimization: Use caching, CDN, image compression

🚀 Now you can easily create a multilingual WordPress site! 🌍