Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8263607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:10:09+00:00 2026-06-08T04:10:09+00:00

WordPress RSS feed not work when custom filed have ‘&’. i think that may

  • 0

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 ‘&amp’ 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’);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:10:13+00:00Added an answer on June 8, 2026 at 4:10 am

    When you’re saving your custom field, try wrapping it in the esc_html WordPress 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:

    $habitat = esc_html( $_POST["habitat"] );
    update_post_meta( $post->ID, "habitat", $_POST["habitat"] );
    

    However, I would really like to see the way you’re saving your custom fields as I believe that esc_html should be run by the update_post_meta function?


    EDIT

    Try adding this to your theme’s functions.php (right at the bottom):

    function custom_field_filter( $id ) {
        $meta = get_post_custom( $id );
        foreach ( $meta as $key => $value )
            update_post_meta( $id, $key, esc_html( $value ) );
    }
    
    add_action('pre_post_update', 'custom_field_filter', 100);
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two websites that declare an RSS feed, like so: <link rel=alternate type=application/rss+xml
So I have a script that creates a WXR(Wordpress eXtended RSS)/XML file from a
<?php $feed = file_get_contents('http://thexmofo.wordpress.com/feed/'); $xml = new SimpleXMLElement($feed); $xml->registerXPathNamespace('media', 'http://thexmofo.wordpress.com/feed/'); $images = $xml->xpath('/rss/channel/item/media:content@url'); var_dump($images);
I have a simple RSS feed coming in my Wordpress site with php, but
I have a small wordpress & css related problem regarding some elements that are
I need to generate an RSS feed for posts in WordPress that contains more
Wordpress is rendering an RSS feed at http://myurl.com/feed/rss/ but of course there's not actually
the RSS feed of annuncistar.it isn't valid because the & char is not allowed
I have multisite Wordpress blog that have three custom fields that have text heading
How do I consume my WordPress blog's RSS feed to display my latest blog

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.