Word Press expert needed: local hosted points to live...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Word Press expert needed: local hosted points to live...

Post by simonmlewis »

We have copied the database of a hosted Word Press site, and all it's data, top our local machine.

We can only it ok, but when we visit wp-admin, it redirects us to the www version, not the site.local version.

Where is the local settings in the labyrinth of files, to stop it doing that?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Word Press expert needed: local hosted points to live...

Post by Celauran »

WordPress stores absolute URLs in the database. It's pretty insane. Open up your wp-config.php and paste the following into it:

Code: Select all

define('WP_HOME', 'http://example.com');
define('WP_SITEURL', 'http://example.com');
(obviously substituting your local URL for example.com)
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Word Press expert needed: local hosted points to live...

Post by simonmlewis »

Bingo, I'm getting this tho:
[text]Warning: include_once(C:\xampp\phpMyAdmin\site/wp-content/plugins/easy-media-gallery-pro/includes/functions/functions.php): failed to open stream: No such file or directory in C:\xampp\phpMyAdmin\site\wp-content\plugins\easy-media-gallery-pro\easy-media-gallery-pro.php on line 426
[/text]
I assume it's a plugin, but whu would that not be working? Missing file (even tho I copied it all over)
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Word Press expert needed: local hosted points to live...

Post by Celauran »

Could it have something to do with the mix of backslashes and slashes in the include statement? I don't really work with Windows, so this isn't something I've encountered.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Word Press expert needed: local hosted points to live...

Post by simonmlewis »

Sorted it. Even tho I copied it all.... it didn't copy all.

Thanks.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Word Press expert needed: local hosted points to live...

Post by simonmlewis »

Hi.
Got similar issue with the same site now, as we are moving it over to a new host.

This is the code, but we are getting "Error Establishing a Database connection". I know the DB connection credentials are correct.

Code: Select all

// disable redirect
define('WP_HOME', 'http://www.site.com.34spreview.com/');
define('WP_SITEURL', 'http://www.site.com.34spreview.com/');


define('DB_NAME', 'databasename');

/** MySQL database username */
define('DB_USER', 'correctuser');

/** MySQL database password */
define('DB_PASSWORD', 'PASSHERE');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
It's using a preview domain with our hosts, maybe that's a cause, but we need to test it in preview first.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Word Press expert needed: local hosted points to live...

Post by Celauran »

Nothing we can glean from that snippet of code, though the URLs look a little odd. yoursite.34spreview.com suggests it's on another domain entirely, which could be a different physical box, different set up, etc. Impossible to tell. I'd talk to your hosting providers about it. Ignoring WP, are you able to establish a DB connection on the preview host? Either via the CLI or through some other PHP script? At least that will help you identify where the problem lies.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Word Press expert needed: local hosted points to live...

Post by simonmlewis »

We have worked it out - the hosts spotted a slight error in the database name, something I don't think I would have seen if I looked and looked.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply