WordPress RSS feed not work when custom filed have ‘&’. i think that may be XML error with character ‘&’. How could I change to that & to ‘&’ in custom field in wp-php code or any working way?
Error !!
I am using following code
function customFieldFilter($id) {
$meta = get_post_meta($id);
foreach ($meta as $key => $value) {
update_post_meta($id, $key, esc_attr($value));
}
}
add_action(‘pre_post_update’, ‘customFieldFilter’);
When you’re saving your custom field, try wrapping it in the
esc_htmlWordPress function.I’m not sure exactly how you save your custom fields, as you haven’t provided any code, but for me this would be something along the lines of:
However, I would really like to see the way you’re saving your custom fields as I believe that
esc_htmlshould be run by theupdate_post_metafunction?EDIT
Try adding this to your theme’s
functions.php(right at the bottom):This is pure guess-work I’m afraid, I really can’t find a lot of information on custom fields. This should retrieve all of the custom fields attached to the post, on save, and run them through a function to encode the
&character to&which will hopefully fix your RSS feed.