I wanted to add the PHP code below to the `functions.php` file that makes some changes to the image URLs in RSS feeds, but there’s no `functions.php` in the Twenty Twenty-Three theme.
function adjust_feed_image_url($content) {
// Load the content into a DOMDocument
$doc = new DOMDocument();
@$doc->loadHTML(‘<?xml version=”1.0″ encoding=”UTF-8″?>’ . $content); // The ‘@’ is used to suppress XML parsing warnings
// Look for the <image> tag
$images = $doc->getElementsByTagName(‘image’);
foreach ($images as $image) {
// Get the <url> tag
$urls = $image->getElementsByTagName(‘url’);
foreach ($urls as $url) {
// Parse the URL to remove query parameters
$parsed_url = parse_url($url->nodeValue);
$clean_url = ‘https://talebotai.com’ . $parsed_url[‘path’]; // Updated hostname
// Update the <url> node value
$url->nodeValue = $clean_url;
}
}
// Save the modified content and return
return $doc->saveXML();
}
add_filter(‘the_content_feed’, ‘adjust_feed_image_url’);
How can I achieve this with the Twenty Twenty-Three theme?
That theme is a little different because it allows FSE. You can read more here: [https://wordpress.org/support/topic/where-is-the-functions-php-file/](https://wordpress.org/support/topic/where-is-the-functions-php-file/)
You could use the plugin they mention or my go to is [https://wordpress.org/plugins/child-theme-configurator/](https://wordpress.org/plugins/child-theme-configurator/) but never tested it with this theme.
The goal is to create a child theme and activate that theme on your site. Then you edit the child theme functions.php. You should never edit the function.php of the parent theme because updates overwrite the changes. Always a child theme.
You should never add code like this to a themes functions file. Instead, you should make a custom plug-in for your site specifically.
You can use the [Code Snippets](https://wordpress.org/plugins/code-snippets/) plugin to run that snippet. Or turn it into a standalone plugin. The functions.php file of your theme is not for that purpose