Try using sanitize_text_field instead of esc_html
wp> $search_query = "Dalton's Law <br/>";
string(18) "Dalton's Law <br/>"
wp> $query = apply_filters( 'get_search_query', $search_query );
string(18) "Dalton's Law <br/>"
wp> $esc_html = esc_html( $query );
string(29) "Dalton's Law <br/>"
wp> $sanitized = sanitize_text_field( $query );
string(12) "Dalton's Law"
esc_html
should be used to escape output before it goes into HTML.
Related Posts:
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- How to get user_id from wordpress database inside ajax function?
- Meta_query compare operator explanation
- Nested meta_query with multiple relation keys
- meta_query ‘compare’ => ‘IN’ not working
- Sorting: custom query with orderby meta_value_num THEN by title
- WP_Query with checkbox meta_query
- Query Multiple Post types each with own meta query
- Meta Query with date and time on the same Day before given time
- How to grab metabox value in wp_query meta_query key
- Is “orderby” in WP Meta Query conflicting with Meta Query?
- Ajax Infinite Scroll In Custom WP_Query Loop Not Working
- How can I create a WP_Query that returns posts where one meta_value
- WP Meta Query for some meta (array) values
- Sort users by meta_value_num
- meta_query with array as value
- How to count data records in wordpress which have same meta_value in wp_postmeta table?
- Using WP Query to search within ALL keys in meta query
- WP Query – Get WooCommerce Products with variation that is in stock
- Meta_query with or without value
- WP_Query orderby breaks when using AJAX?
- Create unique page without header.php for json feed
- Extending woocommerce admin product search
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Using Ajax to load more posts | Help me change the wording on my button to notify the user
- Custom query based on meta key – Reduce three states to two in results?
- Performance when getting post meta for post retrieved by meta value
- Adding an array from a query string to a WP meta_query
- Ajax load more posts – WP_Query parameters not working
- Query multiple meta values
- Query by multiple meta elements not seeming to work – wordpress is timing out
- How to display multiple custom fields with the same meta_key in an ascending order?
- Meta_query with multiple keys and multiple values
- Tax query AND/OR meta query [duplicate]
- Help ordering Post loop by two meta values
- meta_compare not comparing whole integer
- how update data through ajax and jquery
- Error with function in functions.php?
- Use Ajax To filter posts?
- meta queries do ‘either/or’ checks
- Is this meta query problematic?
- Selecting posts with a given meta value for a meta key
- Appending to existing WP_Query’s meta_query if exists
- AJAX Breaking Offset Argument In WP Query
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- Get every post with value in meta key
- WP_Query offset is returning post from prevois loop
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Custom query filter by ACF date custom field
- Does WP_Query ‘responds’ badly to empty arguments?
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Nested array issue in meta_query
- Error in meta_query not get result
- ajax wp_query conditional tags not working
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- How to get current page nearest parent id?
- meta_query with array as value with multiple arrays
- Why doesn’t my WP Meta Query return any results?
- Sort posts using multiple custom fields and menu_order in single query?
- WordPress AJAX Request returns 400
- Order (by ASC) posts with meta_key so posts without values are last
- meta_query – check for multiple meta values in key which holds an array of values
- WordPress Meta Query Null Values Order
- show most viewed post
- Searching for a specific month in a metadata saved as Timestamp (Wp_Query)
- WordPress live search and filter
- Why can my filter query SOME metadata but not other metadata?
- Getting posts by custom field value
- Finding post ID dynamically on click
- WP_Query on custom key and value
- Get posts having meta value between two numbers
- wordpress multiple meta value query is not working
- Strange results from WP_Query
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Sorting with meta_query and multiple, optional meta keys
- meta_query with relation = AND not working as expected when combining EQUALS with NOT EQUALS
- WP Query for Multiple Post Types
- Query by meta value (add a dropdown of all values)
- Order Posts By Custom Field That is an array of objects
- Orderby query does not work for custom fields even with meta query
- make query more simplest and in one query
- WP_Query returns empty if meta_query has more than 7 values
- Fetching $_POST from Page Template into functions.php
- Use not custom fields in get_posts() meta_query?
- I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views
- Compare meta key separation
- WordPress meta_query not working
- Why is $wp_query fetching nothing?
- Using orderby with 2 meta keys
- Inline Ajax call after term is appended with a @ or # etc. displayed in div
- Passing conditional arrays to WP_Query() [closed]
- WordPress Query Default Order if Meta Values Same?
- Wp query by 2 meta field – check if they exists / have value
- Get all user with both meta_value
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Refresh wp_query with no changes
- Use meta query only 3 or more results?
- Use value from meta key array for use in WP_Query
- WordPress – Optimize the Meta Query for 3 meta keys at a time