Theme functions

Free6 min read

All guides

Lango7 has three PHP functions for themes and child themes.

lango7_current_language()

The current language code, or null on your original pages.

<?php if ( lango7_current_language() === 'fr' ) : ?>
  <p>Livraison gratuite en France</p>
<?php endif; ?>

lango7_url( $lang, $url = null )

A URL in a language: the current page, or any URL on your site.

<a href="<?php echo esc_url( lango7_url( 'fr', home_url( '/contact/' ) ) ); ?>">Contact</a>

lango7_languages()

Your languages, each with code, prefix, name, native_name, dir and url (this page in that language).

<?php foreach ( lango7_languages() as $l ) : ?>
  <a href="<?php echo esc_url( $l['url'] ); ?>"><?php echo esc_html( $l['native_name'] ); ?></a>
<?php endforeach; ?>

Wrap calls in function_exists() if your theme may run without Lango7.