Filters that control how Lang Forge detects and resolves the current language.
pre_get_posts — Language Filtering
Lang Forge filters the main query to show only posts in the current language. Priority 10 is used for general filtering, priority 5 for front page resolution.
// Add your own pre_get_posts AFTER Lang Forge (priority > 10)
add_action('pre_get_posts', function ($query) {
if (!$query->is_main_query() || is_admin()) return;
$lang = lf_get_current_language();
// Example: exclude a category for English visitors
if ($lang === 'en') {
$query->set('category__not_in', [42]);
}
// Example: change posts per page for German
if ($lang === 'de') {
$query->set('posts_per_page', 5);
}
}, 20);locale — Locale Switching
Lang Forge filters the WordPress locale to match the current language. This affects date formatting, number formatting, and WordPress admin translations:
// The locale is automatically switched. For example, when viewing /en/:
echo get_locale(); // 'en_US'
// When viewing /de/:
echo get_locale(); // 'de_DE'template_redirect — Language Cookie and Content Switching
At template_redirect priority 1, Lang Forge switches to the translated content version if available. At priority 2, 404 pages are redirected to the homepage in the current language.
// Run code after Lang Forge has set up the language
add_action('template_redirect', function () {
$lang = lf_get_current_language();
// Your logic here - language is guaranteed to be resolved
}, 10);option_page_on_front — Translated Front Page
Lang Forge maps the page_on_front option to the translated page ID for the current language. This ensures is_front_page(), breadcrumbs, and menu active states all work correctly.
—