0

I'm having some difficulty in making a sandbox from a website, and one of them is that wordpress is registering the absolute path of the image in posts.guid field:

http://example.com/path/image.jpg

I think the correct one would be just the relative path, ie

/path/image.jpg

So if I make a copy of the database and try to use it in another domain, or even sub-domain, the images will not appear.

How to solve this?

  • A search replace via WP CLI usually does the job. Also keep in mind that using relative URLs could lead to issues on multisite installs with mapped domains when using switch_to_blog or in RSS feeds when viewed elsewhere – Tom J Nowell May 15 '18 at 1:03
0

Well, after a little research I realized that it is an (inconvenient) feature of Wordpress to store the absolute path of the images and other files, something that I completely disagree with.

In any case, I discovered this plugin https://wordpress.org/plugins/root-relative-urls/.

It does not fix the urls of files already inserted, but it corrects those of the new files.

For a new installation, I understand then that this is an essential plugin.

In the meantime, I'll try to figure out how to fix all the fields of all tables that contain an absolute path.

0

Well, after reading this article https://yoast.com/dev-blog/relative-urls-issues/, I was demoted to accept that Wordpress really is right in leaving the absolute urls.

And I also noticed that the migration process is greatly facilitated by using this plugin: https://br.wordpress.org/plugins/all-in-one-wp-migration/ Thus, everything becomes easier and respecting current best practices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.