Fixing locally hosted wordpress site for migration (removing localhost) - wordpress

A Wordpress novice and have set up my site locally using MAMP.
Unfortunately all the links to styles and I assume the database etc are by default pathed using 'localhost' so the site works ONLY on my machine. What is the correct way to change this pathing so that wordpress will correctly display the site?

For the database, you can edit the wp-config.php file at the root of your site.
As far as your styles are concerned, you'll have to go through the theme files that you've setup and adjust the relative path to those style sheets.

There are several options. Kyle is correct about editing wp-config.php, that will definitely take care of the new DB connection. However, I would advise against a manual adjustment of stylesheets and markup if possible. The easiest way for a novice might be this: export the DB from your local installation using "Settings > Export." Then, in your remote installation, use the WordPress Importer and it should tidy up all the links for you. This has worked for me several times.
You can learn more about other options here: http://wp.tutsplus.com/tutorials/hosting/how-to-break-a-wordpress-install-and-fix-it-again/
UPDATE: unless of course you've hardcoded "localhost" in your stylesheets and markup. In that case, use one of the solutions in the above link.

If your theme uses serialized data, you might have a problem when moving your website by simply doing a find and replace and changing the URL that way. I would recommend following WordPress's guide when you're moving your site.
http://codex.wordpress.org/Moving_WordPress
It involves using a special script to change the URL of your site.

Related

Restarting a wordpress project

I am a freelance developer, and I normally build sites from scratch without using any code generating sites like WordPress or Square Space. But my current client insists on using WordPress. However, I am rescuing this project from a previous developer who made a big mess because from the looks of it does not seem like they knew what they were doing.
Is there a way for me to restart everything, on a clean slate and template on WordPress? I would like to have none of what the previous developer has done. Also is there a way for me do do direct coding using HTML, CSS, JavaScript etc on a WordPress site?
Yes, you just need to look into how to create a theme, since themes are the basis of the Wordpress structure. Ultimately, if you have the code for a website, it can be broken into separate files that Wordpress can use.
See: http://www.wpexplorer.com/create-wordpress-theme-html-1/
If the previous developer has done all the work in the theme files, then simply switching the theme to a default theme (Like Twenty Sixteen) will give you a nice clean slate to dig in and jump off with. You will want to create a child theme of any existing theme if you want to make any changes. If, however, the developer has messed with other files besides the theme folder, then you will most likely want to export the content only (as a logged-in administrator, go to Tools > Export (here's a screenshot))
Then on a new environment (I prefer testing these things first on a local virtual environment like VVV, and then transition to a development subdomain on the same server that the site will eventually go live on and securing it with an htaccess user/password to block curious eyes), import the content on a fresh installation of wordpress via the same menu (Tools > Import). This will give you a fresh installation with the content that's been created, but without any of the mess.
For more information about importing content - here's the codex article.
I hope that's a good start - but if I've glossed over anything you don't understand, let me know - I'm happy to help.

Moving WP site to another domain

I have simple 4.2 WP site with theme Twenty Twelve and Polylang plugin ver. 1.7.6. in domain mysite.co.nf. Now I deciced to move it to another domain mysite.newdmn.eu. I have copyed all files from old domain to new one using FTP. Then have exported DB to SQL script. Have edited SQL script by replacing strings mysite.co.nf with mysite.newdmn.eu using Notepad++. Then I have imported this SQL to my new site DB, edited wp-config to connect to new DB and from first point of view site is running except several things:
No header picture. (Actually this is not problem, but strange..)
No multi language icons and it is not possible to switch between languages.
Can't open one page - new server shows that it not exists. This is simple text page that looks the same like other ones. Link of this page looks the same structure like other pages.
How to solve these problems?
And what is best practices while moving WP sites?
Edit SQL by using editor is always a bad way to update the domain url. Because themes and plugins may serialize php objects into string format and store it in DB. If you replace domain url by using editor, it may break your site.
WordPress codex mentioned : https://codex.wordpress.org/Moving_WordPress#Changing_Your_Domain_Name_and_URLs
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.
The suggested way is to use search and replace tool like https://interconnectit.com/products/search-and-replace-for-wordpress-databases/, or some backup plugin like Duplicator or Backup Buddy.
Also suggested this well written article about WordPress migration.
http://www.smashingmagazine.com/2013/04/moving-wordpress-website/
For me, I always do it by myself without using any plugins. My steps is as follows:
1.move all files under wp-content
2.import db
3.do search and replace by using https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Few times I had to update not only domain but also file path on server.
But the best you can do is using Backup Buddy (paid) or Duplicator (free) plugin (or any other that fits you, but those two are the best imo, and I do at least few migrations a month).

Duplicate an entire Wordpress site in the same domain

I have a live site built in Wordpress at www.site.com/name1.
The client wants a new theme. I've heavily modified the current theme with custom code and will need to do so with the new theme, all without interrupting the live site, so this wont be as simple as moving the site from one theme to another. Therefore I think I need to create a duplicate of the site at www.site.com/name2 because the content will all be the same. Doing this will give me a place to work on the redesign.
What is the best way to go about doing this? Should I have both use the same DB or not? When I get ready to go live should i simple redirect the domain to /name2 or move everything at /name2 to /name1?
Any help is appreciated.
Thanks,
Chris
If you want the same Data you can use the same DB but there is somes Options Tables dans Meta tables in the Wordpress DB, then if you change parameters on one site it will affect the other.
If you just recode the Theme without touching anything in the configuration you can use the same DB to test your theme with valid datas, but if you think you'll have to change paramaters i would prefer duplicate the Production DB to a Test DB to secure the production Website.
When you go live you'll just have to move your theme to the production website and copy your Option and Meta Tables.
If you're at a point where you're having clients, you should definitely develop locally. This will free you from the trouble of mistakingly messing up the production site.
Install Apache, MySQL and PHP on your own machine.
Copy database and files from production.
Change anything you'd like without exposing it to the Internet.
Upload your new, tailor-suited theme to production when it's ready to go live.

wordpress theme doesn't appear

I'm having a very basic problem: I'm trying to create a new theme for a wordpress installation locally on my computer.
I've created a styles.css and index.php file and put it in a folder in wp-content/themes. But it doesn't appear in the Wordpress themes page.
As a test, I made a change to the description of one of the existing themes (Twenty-Ten) in its style.css, and refresh the Wordpress themes page, but the old description continues to be shown. This suggests to me that I'm simply using the wrong folder, but that's not possible! Any ideas on this problem much appreciated.
UPDATE: In fact, even when I delete Twenty Ten from the Themes folder, it's still available as an option in the Wordpress backend, and I can activate it... Very strange...
G
I agree with your diagnosis. You are either looking at the wrong folder or in fact the wrong computer. There's no other way that you could change the theme to one that has been deleted.
I suggest that you confirm you are in the same universe you think you are in. Create a simple file localserver.txt in your WordPress directory and then confirm that you can access that file.
If you can't, you have your answer. You are somehow accessing a different location.
If you can access that text file, you need to go further and look to see if something like the site url setting is redirecting you to the live site, without you realizing it, when you access wp-admin.
Beyond that, I'd need to know more about your setup. Something like having www.example.com in your /etc/host file and not example.com can cause similar confusion...
Are you using Wordpress Multisite?
In that case you have to 'enable' that theme in the Network admin manager

CSS not applying in my DRUPAL 7 site on localhost

I'm working with Drupal 7.2, till now i have worked on somebody's localhost,now i decided to work on my own PC, so i make a copy of original code form other's PC and paste it to my localhost WAMP and also upload database into my localhost/phpmyadmin, but some how its not working at all.
CSS not been applying to the site, its displaying all the content without CSS. can anyone help me for this issue?
I tried out by clearing a cache from admin side as well as from browser.
Thanks.
Not just the cache but the aggregating too make sure you clear all the check boxes
Cache pages for anonymous users
Cache blocks
Even those under bandwidth optimization
Aggregate and compress CSS files.
Aggregate JavaScript files.
Works like a charm. Thanks guys
Presumably you're seeing the Drupal site itself (implying your db/web server/php settings are ok) but just unthemed? Have you tried clearing the Drupal caches? As you lifted the database from another host it's possible you might need to do this to force drupal to rebuild it's menu paths.
You should check the source code of the site on your localhost and check that the file paths to the css style sheets is correct. Using Google Chrome Developer Tool you can update the paths and see when they take affect or just keep updating your templates until you get it right. Also check that any options in the database are using your localhost and not the other domain
You may try following to debug:
Clear Drupal cache from admin/settings/performance.
Rebuild theme registry.
Add a new theme to your site and see if it is rendering the content properly.
I see the same problem, yet no solution suggested has resolved this... I notice in source code that it seems to truncate the css paths to be at site root i.e. < link type="text/css" rel="stylesheet" href="http://dev.drupalsite.com/installed_dir/ media="all" > ... hmm

Resources