How Do I Create a Relative Path in WordPress?

Creating a relative path in WordPress is simple. To do so, first make a new folder in your WordPress site and name it “wp-content/uploads”.

Next, inside of this folder, create a new file and name it “relative.php”. Inside of this file, add the following code:.

Now, inside of your WordPress theme’s functions.php file, add the following line:

add_action( ‘init’, ‘relative_path_init’ );

Finally, add the following line to your theme’s header.php file:

Relative paths in WordPress will now be relative to the “wp-content/uploads” folder.