Skip to content

Translating "Days Ago" via %s Variable and Setting Correct WordPress Site Language

Control how the elapsed-time date on your ads, blog posts and quick view reads: put your own wording around the %s variable, and let WordPress translate the time units themselves.

2 minute read

This article focuses on how to translate texts in your single ads template, blog posts, quick view, and many other modules that show the time elapsed since a particular post or ad was added to your website.

This text function is based on default WordPress functionality, and as theme authors, we do not duplicate functions that already exist. This text can appear in various forms, displaying when an ad was added, for example:

  • 3 hours ago
  • 6 days ago
  • 3 months ago
  • 2 years ago

Change the wording around the date

To translate these texts, visit Listivo Panel > Translate & Rename and search for the "%s ago" text string. %s is a variable that represents a number followed by a time period (e.g. 3 hours, 3 days, 3 months, 3 years), and you can place it anywhere in the text to adapt it to your language preferences. You can add text before and after it, as shown below by placing the variable in the appropriate place.

The configuration as above will result in displaying dates like this:

Translate the time units themselves

The time units come from WordPress, not the theme
Text such as "2 years" (or months, days, hours) cannot be translated in Translate & Rename, because it comes directly from the WordPress site translation.

If you use Spanish, for example, make sure your website's Site Language is set to Spanish in wp-admin > Settings > General.

This will automatically translate all "years," "months," etc., text strings to your language.

Ask the people who build MyHome

We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.

Was this guide helpful?