Add the Website Translator on a WordPress website

Learn how to publish your website translation in Smartcat by adding the provided JavaScript snippet to your HTML pages or CMS, with specific instructions for WordPress sites.

To publish your website translation, add the JavaScript snippet that you received from the project manager to the section of your HTML pages.

  • If you use a CMS, locate the <head> section in the CMS settings and inject the snippet to it

  • Otherwise, simply paste the JavaScript snippet on all your website HTML pages just before the </head> tag.

The following example shows a website section before and after adding the JavaScript snippet:

Before:

<html>
  <head>
    <title>My awesome site</title>
  </head>
  <body>
  ...
  </body>
</html>

After:

<html>
  <head>
    <title>My awesome site</title>
    <script name='sc-script' src="https://cdn.smartcat-proxy.com/82bff1afdc20cc9e54b718c5458c599a/script-v1/__translator.js?hash=58d70a36d02ba2102062940dae75b3e8"></script>
  </head>
  <body>
  ...
  </body>
</html>

Make sure that this JavaScript code is enabled on every page of your site. If a template is applied to every site page, update the template by injecting the JavaScript snippet as described above.

The following example walks you through the process of adding the Java snippet to a WordPress site.

Adding code in WordPress

There are a few ways to edit the HTML in your WordPress theme. The ability to edit them is open only to your personal installations or WordPress Pro.

  1. Log into your WordPress dashboard and navigate to Appearance.

  1. Select Theme File Editor

  1. Under Theme Files, select header.php:

  1. Paste the JavaScript snippet just before the </head> tag.

If the PHP change results in an error, upload the change by modifying header.php directly. To do it, log in to your hosting, navigate to the file manager and locate the folder with the theme that is currently applied on your WordPress site:

Then open header.php and add the JavaScript snippet as shown above.

Need some extra help with you WordPress website? Smartcat recommends Codeable for our preferred WordPress development resource.