You need to escape data while displaying also. Use esc_attr
in your case. Try this:
<input type="text" name="field_name" value="<?php echo (!empty($field)) ? esc_attr( $field ) : ''; ?>" />
Check this for full documentation – https://codex.wordpress.org/Data_Validation
Related Posts:
- Proper Way to Sanitize Meta Input
- Sanitizing integer input for update_post_meta
- Should I sanitize custom post meta if it is going to be escaped later?
- Correct processing of `$_POST`, following WordPress Coding Standards
- How to sanitize post meta field value?
- Copy content stored in meta to post content
- Can A Post Meta Field Store multiple values that are not in an array?
- esc_attr on get_post_meta [closed]
- Data not displaying in text field
- Extend file format support for post thumbnails
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- How can I get the post ID from a WP_Query loop?
- How to edit a post meta data in a Gutenberg Block?
- How we get_post_meta without post id
- What is the code to get the download link for a product in WooCommerce?
- How to update/delete array in post meta value?
- How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
- Get Advanced Custom Fields values before saving [closed]
- Why am I getting an infinite loop with have_posts?
- How to store post meta in an array?
- adding a URL to a post meta
- update_post_meta() not working when used with WordPress action
- Adding meta data to an attachment post
- Get posts by meta value with date
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Problem With Order Item Meta In Woocommerce
- Job of meta_key meta_value fields in database tables
- Query 2 meta key values and a category
- Best way to save postmeta
- vs WordPress Security
- How to add meta data to WordPress posts?
- How to update Post Meta values through the comment system
- Filtering multiple meta_values
- how to build (custom) stats for post views, per month
- get_post_meta pagination
- How add post_meta from user_meta?
- How can I get my iFrame to work with url from post_meta?
- How to use update_post_meta() function properly?
- Hey, I want the second options. get_post_meta()
- Update post meta in woocommerce order frontend
- How to display post view count by date, week and month?
- How can I filter posts when the meta_value is a serialize object?
- Get User Post if Private
- How do I dynamically call a page/post author into the meta data?
- Set Condition echo function get_post_meta
- Unknown characters added to meta data values
- Unable to sanitize in customizer and escape in theme without removing ability for user to use “< br >” to insert a line break
- get_post_meta($post->ID) returns empty string when in preview mode of custom post type
- need to add add user names to the post for later retrieval or removal
- Trying to get property of non-object error using get_post_meta()
- Like & Dislike functionality using JavaScript
- update_post_meta not working in plugin
- get_permalink vs the_permalink
- Updating my Post when expiry date is past
- How to remove Date from Meta Description on SERP?
- How to display sql query fired by posts_where
- Unfiltered html with update_post_meta
- get meta value from page query
- why after saving meta value it’s saving all the values the one that i clicked?
- How does WordPress treats attachments metadata in post content?
- Retrieving post meta array (attachment)
- Stop `update_post_meta` from working each time page refreshes?
- wpdb->get_var – count author posts, meta value
- Displaying the ‘time ago’ for recent activity within a post/custom post type?
- add post meta front end edit
- How to query and update one colum in postmeta table?
- How to remove date from showing in meta description
- How to save HTML data into SQL post_content column
- update post meta value with other post meta value
- Post Publish date not display on Umaya Child themes
- How to merge the database results into single result?
- Check For get_post_meta on Author Archive Page
- Negative meta_query if storing multiple post_meta values with shared meta_key
- How can I update this array built from post meta data?
- What format is this and how to get value “lal” and “pila” from it
- Frontend query and does not need to log in [closed]
- Get data from custom table and update relative post_meta based on meta_key
- How to save a meta_value as a numeric value after I retrieve it via update_post_meta?
- Get or set values in post meta
- Display multiple meta_key/meta_values by single SQL query
- Programatically delete several attributes in _product_attributes in post meta
- Get post meta after insert post
- How do you sort the items in a custom taxonomy meta box?
- WP-API + JS Backbone client – how to update post meta
- update_post_meta returning false when called during init
- post_title in save_post action
- Getting meta content from get_next_post & get_previous_post
- When importing posts to a new site if XML file has postmeta not setup on new server what happens?
- Access Serialized Post Meta Values
- Cache metadata for set of posts
- Does post-meta belong in header?
- How to use esc_attr__() function properly to translate a variable that contains string?
- Problem with get_post_meta
- How to show wordpress post in the site based on custom field value?
- wordpress query making site very slow
- if condition from post_meta not working in save_post
- I read the postmeta and update it without changing it, then move on to the next record
- Why isn’t my embed_video WYSIWYG field updating when using update_post_meta?
- Calling metadata in a single.php file
- Add specific postmeta to search query