Wordpress find and replace image URLs not working - wordpress

I have migrated a wordpress site from a subdomain on my host, to my client's domain on their host. Only the image URL's were still linking to my subdomain. I used a find and replace plugin as well as going straight through phpmyadmin to modify the database with a find and replace command as well. I believe I was successful in changing the URLs, but apparently they are wrong, as there is an extra folder in the URLs. Now when I try to correct this, find and replace does not detect the (incorrect) URL I am trying to replace with the correct one. I have tried many variations of the URLs, from the entire thing to just parts. Any thoughts?
Trying to replace:
http://www.themaggiedress.com/public_html/themaggiedress/wp-content/uploads/
with:
http://www.themaggiedress.com/public_html/wp-content/uploads/
in the database.

Have you tried updating your permalinks?
Also make sure your 'WordPress Address (URL)' and 'Site Address (URL)' are correct in general settings? (It should not reflect the Sub Domain)
You can also manually look for the images in your Wordpress directory and make sure the links are right when investigating them in the browsers console.

Related

moving WordPress over to domain, after working on it locally through MAMP

I've finished the styling changes on WordPress and I'm ready to move it from MAMP to my domain.
Will this involve any changes to the WordPress files or can I just drag it over to my new domain once I purchased it?
The main start you must make is update your wp-config.php
define('WP_HOME','http://www.mynewdomain.com');
define('WP_SITEURL','http://www.mynewdomain.com');
That way wordpress knows what domain it MUST run from.
The reason you do that is because without this you may not be able to access admin, login, etc etc.
When this is working and you have logged in, go to wp-admin and go to your permalink settings.
Make a NOTE of your settings, then change them to default (and woocommerce settings etc).
Go to your home page and a few others, and notice how messed up your urls look :)
Now go back to permalink settings and restore them (the point of this is to make sure your .htaccess file that wordpress depends upon is set correctly)
Finally, have a look at https://github.com/veloper/WordPress-Domain-Changer to change your sql etc if needed.
note this method is very handy for developers so you just update your wp-config.php for localhost or development or production (not for testing purposes, don't use your local pc. copy it all up to a subdirectory of your hosting partner e.g. http://www.mynewdomain.com/mytestarea. Make sure you use a COPY of the mysql database (never point both to the same database). You now can test on the hosting platform without disturbing the live site or your development causing issues to other people.
It's been a long while for me personally, but you'll want to change the SiteURL via the options menu in wp-admin.
Otherwise, just make sure your MySQL database is exported over, your credentials and user permissions are all setup and those work too.
If you still have problems:
https://codex.wordpress.org/Changing_The_Site_URL
https://codex.wordpress.org/Moving_WordPress
The database has to be updated. What always works for me is that I export the database from phpMyAdmin or MySQL (using mysqldump) and open the exported .sql-file with a text editor, like Sublime Text.
Now you want to find any occurence of your previous URL. Let's say on your dev machine the URL to the index of your Wordpress site is http://localhost:8080/wordpress and you want it to be on a website under https://domain.com you simply do a Find & Replace using that and replace everything with https://domain.com.
For older Wordpress versions you have to update the .htaccess files if you have custom URL's.
You have to make a search replace in your database and replace your local domain ( test.lo ) with the live domain ( test.com ).
To do this you can use the script from here: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Add the searchreplacedb2.php file in your route folder and the access test.lo/searchreplacedb2.php and follow the steps there. This will replace your local domain with your live one everywhere in the database.
You can't make a simple search-replace because the local domain might be serialized in some fields in the database, and a simple search-replace will not replace those.

Transferring Development Wordpress To Live Wordpress Without Issues

I am looking for a way to port one wordpress install across to another site.
For example, say I have:
development.example.com
example.com
I want to transfer everything from development.example.com to example.com
Transferring the domain name is always a pain for me and I am hoping someone can help me.
After transferring to a new domain and hosting, I normally have to go into the wordpress database into the options table and change two fields.
siteurl and home (I change these to my new domain name)
I can then run example.com/wp-admin and I will be able to login.
The above works fine on the basic setup, but the issue I am having is that when you have lots of different plugins all adding options and other fields to the database it turns into a bit of a nightmare.
I normally have to remove the plugin folder and reinstall them one by one, and then use a search and replace plugin to change all the options from.
search: development.example.com
replace: example.com
This all seems like a very long winded process considering when I build with codeigniter you only have to change the url in one place config.php and then just run a
cp -rf development.example.com/* example.com
Could someone advise me on how they normally run a transfer with wordpress where all this search replace and login issues aren’t needed.
You have all the details on the When Your Domain Name or URLs Change section in the Codex.
For replacing links, the Velvet Blues Update URLs plugin works well for me.

Change Wordpress URL from example.com/wordpress to example.com/blog

It seems like an issue that has been talked about a large number of times, but for some reason, I can't seem to get it to work.
Goal: Change Wordpress site from example.com/wordpress to example.com/blog
Here is what I've tried:
Changed the Wordpress root folder from "wordpress" to "blog"
Then, in phpmyAdmin, changed the siteurl and home url's to example.com/blog
When that did not work, I also went into my theme's functions.php file and added:
update_option('siteurl','http://example.com/blog');
update_option('home','http://example.com/blog');
immediately after the opening
<?php
tag.
Is there something I am missing?
When your domain name or URLs change - i.e. from http://example.com/blog to http://example.com, or http://example.com to http://example.net - there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display.
If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options:
1- Only perform a search and replace on the wp_posts table.
2- Use the Search and Replace for WordPress Databases Script to safely change all instances. ( If you are a developer, use this option. It is a one step process as opposed to the 15-step procedure below )
Info taken from http://codex.wordpress.org/Moving_WordPress
Search and Replace for WordPress Databases Script: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
You need to update all URLs in your database too.
Take a look at this script:
http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
You could try this plugin:
http://wordpress.org/plugins/wp-migrate-db/
From its own description:
"Exports your database, does a find and replace on URLs and file paths, then allows you to save it to your computer."

Changing the URL of a wordpress site

I have a wordpress site at http://myname.myprovider.info and I just bought the domain http://www.myname.com
Ive tried to change the URL in the backend at "Setting > General" both fields WordPress Address (URL) and Site Address (URL) with http://www.myname.com. The moment i click save, Im automatically logged out of the backend. If i try to log back in, I get a white screen.
The only way to log back in is to add in the config file the following line:
define('RELOCATE',true);
If then I go back to "Settting > General" I see that WordPress Address (URL) still has the http://myname.myprovider.com and everytime I try to change it again, the loop starts again...
What can I do?
you cant just change the url in wordpress ... you would need to move all the files to your new host
you can facilitate this in wp-admin
under tools select export and follow the dirrections
then setup wordpress on your new host
and goto wp-admin and select tools import and select the earlier exported file
If you're moving from a subdomain to the main domain, you have to move files. See Moving WordPress « WordPress Codex and How to Move WordPress Blog to New Domain or Location » My Digital Life and check with your host; the URL structure "myprovider.info" may be problematic, whoever the "provider" really is.
I had a very similar problem some time back and I'm trying to remember what the source of the problem was. Until I do, here are some ideas you may or may not have tried:
(obviously backup everything first!)
Check your code (theme, scripts, functions.php, etc.) for any instances of the old URL. Sure, we all know better than hard-coding the URL but...
Do a search through your WordPress database for the old URL. Carefully (very carefully!) replace it with the new one. In my experience some plugins aren't well behaved when it comes to storing the web site URL in the database.
Try disabling all plugins to see if one of them is causing a problem.
I assume you've set the DNS by hand, rather than your domain registrar putting in place some kind of forwarding?
After much tinkering, it turns out I didnt configure the domain properly :P Thanks for all the help anyway.

wp print_thumbnail function is not working

wordprees print_thumbnail function is working correctly on testing server but it's not working on online server and giving wrong image path such as */var/www/vhosts/vinehospitality.co.za/httpdocs//wp-content/uploads/2011/12/slide-10-108048_56x56.jpg*.
So kindly help me to get proper url.
Link of website: http://vinehospitality.co.za.plesk15.wadns.net
Same problem is found in hosted on this server.
Regards
Neeraj
Not only did it work, it was SO MUCH easier for me.
Simply, delete whatever custom link you have in Media Settings. If you don't have one just put anything there..
Then save, again, put back the original path you have before, save.
Worked!
Somehow it seems wordpress reads the wrong values when you move servers and you don't resave media settings.
POSSIBLE FIX 2
Look, I've seen this problem on other threads and on other websites and no one gave information that helped most of the people with this issue, so since I somehow got my broken site to work, perhaps it will help the others who did not get their problem solved.
Here's a little background... I needed to move a wordpress site located on a dev server to the live server. They were different domain names of course. First of all, I should have followed Moving Wordpress instructions and updated the site url before I exported the database, but... I didn't because I'm obviously too cool for instructions.
In order to transfer the site, I zipped up the files and transferred them to the new server and unzipped them. Then I edited wp-config and pointed it to the new database.
I used phpmyadmin to export the old database and I imported it to the new database.
Then I ran a query on the wp_posts table to do a string replace on the guid field and replace all instances of the old domain name with the new domain name.
Then I checked in wp_options and changed 2 records to replace the old domain name with the new one. I think they were something like siteurl and home.
Everything seemed to be working fine except the theme was mangling the img urls, prefixing them with the absolute filepath.
I figured I must have missed some records in the database that give the print_thumbnail function whatever information it needs to output the right url for the img's src attribute.
I thought if I could change a setting somewhere and change it back, maybe wordpress would automatically fix the issue for me, and I was lucky.
I played around with several settings and what finally worked was:
I went to Media Settings and I unchecked Organize my uploads into month- and year-based folders -- I don't know if this had much to do with the fix.
I also changed the Store uploads in this folder to something like wp-content/uploads2. I never created that folder, but I just wanted to get it to overwrite whatever was controlling that value.
I checked the site again and there was a change to the html source... now, it didn't even give the img tags a src value... it was just like <img src title="blah blah" />, so I figured I was on the right track.
So then I went back and changed Store uploads in this folder setting and left it blank as it was originally.
After I did that, the img src values were correct.
Hope this saves someone some time.
Also, I should note, I played around with altering the file permissions for the wp-content directory. I wish I hadn't. I get the gist of file permissions, but I tend to try not to fool with them if I don't have to. Using Filezilla is a pain to change the file permissions because it takes forever. Unfortunately, as most clients, this one had a prior affiliation with their web host and refused to take my advice and host their site on a VPS that would be cheaper and allow me to use SSH and get work done much easier. I wonder if there's a fast way to chmod multiple files without ssh, I should look into that.
Cheers,
Will
Will's approach fixed the error for me, and was in fact the only answer that worked. This question is posted hundreds of times, so I figured I'd summarize the answer in short. I'll post the answer first and the research details after.
Login to WordPress
Goto Settings > Media
In "Uploading Files", modify the "Store uploads in this folder" to "http://www.yourdomain.com/wp-content/uploads2"
Notice the "2" added to the folder-name
Delete any entries in "Full URL path to files"
Save changes
Now your site should already show some images again
Do all this again but now change it back to "http://www.yourdomain.com/wp-content/uploads"
Save changes
This finally worked for me.
Gathering from other sources, this occurs mostly after moving a website from one location to another. Other fixes I did prior to this:
Within MySQL, replace the old URL in the GUID values in "wp_posts" to the new URL
Change "chmod" settings (it you never had any prior issues, don't)
Many other answers to this issue included changing chmod to give access to the files, which didn't do anything but crash the website. Other solutions would've been to change the code entirely to use a different function. I figured it's not broken, just missing a setting. Turns out that was the fact.
It worked for the domain http://www.in1week.nl, which runs on a modded DeepFocus template by ElegantThemes.com. The theme uses "timthumb" in the function "print_thumbnail()", which may have caused the issue. This reset the value needed to use the function.
I faced the same problem and had to look around a lot in search of an answer. After my host moved servers, thumbnails weren't appearing on the home page and category pages. Looking up the source showed me that the path generated for the thumbnails was incorrect. Instead of http://.. in the image paths, I was seeing absolute file paths in the server, such as /home/..
Couple of solutions that seemed to have worked for others did not work for me.
What did not work:
Changing permissions of wp-content/uploads and all the directories under it.
Changing media settings and again reverting back to original settings.
Using 'the_post_thumbnail' instead of 'print_thumbnail' function helped the thumbnails come back, but I am no programmer and could not figure out how to make the_post_thumbnail function work exactly as it was working with print_thumbnail
What worked:
In my many searches, I read someone saying that the problem was fixed by correcting the path for 'et_images_temp_folder' in the database. I ignored this for a while since I did not understand what it meant. Later, I searched wp_options table and found that it had the following entry.
option_name: et_images_temp_folder
option_value: /home/painteds/public_html/darter/wp-content/uploads/et_temp
When the servers were moved my home dir was changed from /home to /home3 Perhaps print_thumbnail was searching for /home folder, and was malfunctioning when it could not find it. Updating the database with the new value fixed the problem for me.

Resources