Skip to content
Custom fields for WordPress that are quick to build and quick to load. Get Pro
Docs

More than one language

Reading in the right language

Nothing changes in your code. ugly_get() and ugly_show() give the value of the language of the visit:

1 minute to read Updated 1 week ago

On this page

You want: the value in the right language, on the page and on an options page.

On the page

PHP
<h1><?php ugly_show( 'headline' ); ?></h1>   <?php // in the language of the visit ?>

Nothing to add: ugly_show() and ugly_get() read the page being shown, and each language is its own page in Polylang.

A page in a specific language

PHP
$english_id = pll_get_post( get_the_ID(), 'en' );
ugly_show( 'headline', $english_id );

On an options page

The same call gives the value of the language of the visit, or of the main language if that one was never written.

Did this article answer your question?