I have a particular CPT post that has a dash (-) in its title. I copy this title in a variable $var
using get_the_title()
then I create a custom field somewhere else with a value equal to $var
: add_post_meta($my_post_id, 'some_name', $var);
Problem: in the custom field, the dash became a HTML entity with a “&”, “#” and a 4-digit number number.
Why, and how to fix the problem?
get_the_title()
is treated withwptexturize()
by default. That changes the dash.To fix it remove the filter and reapply it if it was really set: