If you have static text with dynamic content then you can use.
printf( esc_attr___('static text goes here with %s', 'text-domain' ), $title );
If you have only $title then no need to translate it.
Just escape it.
echo esc_attr( $title );
Note esc_attr
, esc_attr__
and esc_attr_e
used for escaping dynamic values from HTML element attributes.
E.g.
`<div class="<?php echo esc_attr( $class ); ?>">`
And esc_html
, esc_html__
and esc_html_e
used for escaping dynamic values from HTML content.
E.g.
<div> <?php echo esc_html( $title ); ?> </div>
Related Posts:
- Data Validation & Sanitization for Big HTML Blocks
- How to create .pot files with POedit?
- Enqueue Stylesheets After Theme’s “rtl.css”
- Caching and Versioning for rtl.css
- Use __($str) and _e($str) to translate strings with HTML
- Can I create customizer setting that can handle plugin shortcode?
- How to sanitize select box values in post meta?
- What is the purpose of an extra file for translation?
- Translated strings not appearing – what am I missing?
- Remove frameborder attribute from iframes
- 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
- What is the safe way to print tracking code / pixel code before tag or tag
- correct tags for validating input types
- Does the textdomain have to be the theme’s name?
- How to escape html generate by a loop
- How to escape multiple attribute at once in WordPress?
- Do I need to include a textdomain if my theme doesn’t support translation?
- Contact Form Security
- How to allow certain PHP functions when using sanitize_callback in the word press customizer
- Data Validation in wordpress
- 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?
- Trouble creating custom sanitization function when uploading video files
- Enqueue Stylesheets After Theme’s “rtl.css”
- Display Today’s date outside the loop?
- What are these variables and where are they documented?
- Is there a way to prevent wp_head from outputting self-closing tags?
- How to add posts to custom menus?
- How to add custom css file in theme?
- CSS not updating in browser when I change it
- How to remove search bar from a wordpress theme? [closed]
- Get url of thumbnail from the media uploader
- How to: Update live sites theme from version control repo via plugin or library? [closed]
- Adding items to page template dropdown on Page Edit Screen
- How to use logout function on custom menu link?
- Hide certain pages / posts on wp-admin, show custom filter
- use add_action(‘wp_head’) in a widget for generating dynamic CSS styles
- Front End Post Submit Form
- Page attribute template dropdown not displayed even the syntax is correct
- How to add a text widget during theme activation
- WordPress Theme customisation CSS
- Displaying wp menus by name without using theme locations
- Why does this loop only work on the homepage?
- Nesting Functions within Functions
- Theme check: Missing a text-domain
- Can I customize any WordPress parent block-based theme template files by child theme like a parent classic theme?
- How to determine if post has widget content?
- Custom Script Section Only Echoes Text
- WP Customize refresh problem
- Set multiple templates per post
- Place the page title into the short code
- Displaying recent post excerpts on static front page
- approach to pass additional parameter in post URL
- Which html elements should be styled in wordpress theme
- WordPress Media Uploader in page template (On Front-end)
- What data sanitzation function should be used to store entire source code of webpage?
- Theme Customizer not loading JS for live preview
- Replace function in a child theme
- get_search_form() and aria_label
- Can’t remove DIV from hooks in Storefront child theme [closed]
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- How can I specify that an area of my theme contains widgets?
- Extract all shortcode data from post into loop variables?
- wp_nav_menu and its fallback
- Adding the_content() return warning count()
- Copying the theme style files and images to duplicate the website but with a difference
- How to set Post meta-box defaults based on the choices made by user in Customizer?
- Ajax call returns 0 when add_action is inside a class in functions.php
- Woocommerce Product attribute not imported with wordpress Importer [closed]
- header, stylesheet not being read
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- List categories of a post hierarchically?
- Custom Post Types set up, how do I style the main slug page?
- What are the permalinks options for “Category” base and removing it?
- Designing a custom archive.php inspired by the Autofocus theme
- Is a site with 1,500 pages, (1000 of which are E-Commerce Pages) Too Big to Migrate to WordPress?
- How to get blog-id of an MU site from functions.php
- How to register dynamic settings in WordPress Customizer?
- How to add audio files to audio player in WordPress custom theme?
- WordPress theme doesn’t read my translations from pt_BR.po file
- How to get full native language instead of iso?
- Move the social media icons to the left of a WordPress nav menu for Soledad child Theme
- Two instances of the theme folder in the URL
- Next post in category
- Horizontal Navigation
- Custom image size doesn’t work
- How to assign the default file at “Appearance > Editor”?
- Setting different CSS for all pages except home.php
- How to create sub-menu in “Allure Real Estate Theme for Placester”?
- how to sanitizing $_POST with the correct way?