I wanted to add a simple PHP code, but there was no functions.php file in the Twenty Twenty-Three theme. How can I make this change happen?

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?

  1. 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.

  2. You should never add code like this to a themes functions file. Instead, you should make a custom plug-in for your site specifically.


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer