The sweet and short of it all is, never try to translate HTML tags. Use placeholders and either printf
or sprintf
to translate strings with HTML tags
Something like this will do
printf()
printf( __( 'This %s text %s have an %s HTML %s tag. Another sentence...' ), '<em>', '</em>', '<b>', '</b>' );
sprintf()
sprintf( __( 'This %s text %s have an %s HTML %s tag. Another sentence...' ), '<em>', '</em>', '<b>', '</b>' );
Related Posts:
- How to create .pot files with POedit?
- Enqueue Stylesheets After Theme’s “rtl.css”
- Caching and Versioning for rtl.css
- What is the purpose of an extra file for translation?
- Translated strings not appearing – what am I missing?
- How to change i18n/l10n of #reply-title? (Old title: Comment reply link not working)
- Internationalization and functions that use it
- Theme translation not applying
- 2 localizations inside a WordPress theme
- Should I change text-domain of TGM library inside theme?
- Change locale by detecting viewer’s browser language setting and let them choose prefered language after
- Single translation for many locales
- Does the textdomain have to be the theme’s name?
- Do I need to include a textdomain if my theme doesn’t support translation?
- using Options Framework – can “theme-textdomain” domain be changed?
- Translate a theme with a PO file
- how to unlocalize theme/plugin?
- How to set different localization file for different users?
- Menu names not getting translated
- How to generate a rtl.css file for themes?
- Enqueue Stylesheets After Theme’s “rtl.css”
- Display Today’s date outside the loop?
- What are these variables and where are they documented?
- How to use esc_attr__() function properly to translate a variable that contains string?
- how can I add an icon/image for a child theme?
- When to use add_action(‘init’) vs add_action(‘wp_enqueue_scripts’)
- Different ways to display title
- Suggestions for creative use of post format feature, or themes that use them well
- Retrieve the template directory URI via global or get_template_directory_uri() every time?
- Subdirectory install error
- How can i change menu link when page content empty?
- How can I remove specific custom post meta from the “Custom Fields” fieldset?
- How to load different CSS in different Header?
- How can I add an incremental class identifier to my sidebar widgets?
- How to preset a sidebar widget with default content via script?
- Featured Image Size
- the_tags without hyperlinks?
- How to keep theme layout the same when admin gray bar is present?
- Wrong path for theme assets
- one time popup after theme activation
- Create a theme by combining a parent and a child theme
- how do you create an admin interface in plugin for your theme
- Implement advanced search
- Highest number of WordPress Custom Page Templates?
- Difficulty loading jQuery with wp_enqueue_script
- multisite: global menu containing network site links?
- Unable to check if image uploaded by wp_image_editor exists using file_exists function
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- How to add styles set by user in the customizer
- Use second time navigation.js in underscores [closed]
- Add attachment for all images in post
- Is it possible to include an HTML flat-file website inside a WordPress theme?
- Static home page with “Blog” inside?
- Overrite parent functions using child functions
- How can I change the theme of different posts using a plugin?
- Include jQuery (or anything) inside Custom Options Panel’s tag
- WordPress 3 botches my Custom Meta Box values on Save
- Exclude custom post type from search conflict with get_posts
- How to obfuscate theme directory URLs
- Remove specific published page when theme deactivated
- Is there a WordPress boolean for “theme_customizer_active()”?
- Weirdness in jQuery supplied with WordPress
- Post and page content not displaying in search results
- Get Post’s Excerpt Without the Wrapping tags and the Read More link
- Templates dropdown not appearing using _s theme (underscores)
- get_header action not working
- Navbar- disable “onClick” drop-down
- Injecting pre-defined text from custom page template to editor
- How To Display Value from Theme Options Field in Front End Template?
- Changing footer depending on URL (poli language site)
- Update Specific Key Value in Complex `wp_options` object
- Using Foundation 5 off-canvas-menu with WordPress
- multiple queries to get posts from same category?
- Parent/Child pages
- Cart displayed above header
- “The REST API did not process the context query parameter correctly.” Custom theme conflicting with Media Library
- Wrong activation/confirmation link in email
- Post Featured Image Custom Sizing?
- Theme: dropdown hover menu not showing up in IE/Edge
- How to enqueue scripts properly with ES6 webpack?
- Disabling wordpress added class
- how to ensure responsiveness in wp themes? [closed]
- PHP Script on a template page & dealing with URI’s
- home is not working in wordpreess
- Responsive Images with art direction
- Correct form of escaping and localization – functions.php breadcrumbs
- Activating theme in local MAMP installation results in HTTP ERROR 500
- New created Theme leads to malfunctioning Xampp Apache –> functions.php is cause
- Where to find this broken link in order to remove it
- Woocommerce Theme Reviews / Comments
- background_image support multiple image size?
- Support Multiple featured images
- Moving Posts and Users Only to New Site
- Want to display page content after password prompt without page reload
- Programatically add a page in WordPress
- How to highlight current menu bar base on the URL?
- Roll my own theme or customize an existing one [closed]
- Why do some sites show themes/”themename” as the only theme?
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?