How to add a WordPress variable to a translation function open

How to add a WordPress variable to a translation function

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

Wrap your translation function in php printf function  and use %1$s, %2$s


$myvariable = 'something';
$myvariable2 = 'something2';

printf(esc_html__('My translation text for %1$s and %2$s', 'textdomain'), $myvariable, $myvariable2);

If you need to translate with working html tags use

printf(wp_kses(__('my <strong>translation</strong> for %1$s and %2$s', 'textdomain'), array('strong' => array())), $myvariable, $myvariable2);
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation