Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Mark Wardle
Mark Wardle
5,527 Points

Launch Wordpress from localhost

Hey there Treehouse team.

I just wanted to let you know that I am highly anticipating the arrival of the "Launching a Worpress site" module. I've been trying to launch a WP site following the instructions of several tutorials on the Internet, but there has been a problem every time. It seems that the plugins make things a little more challenging.

I can't wait. Please don't take your time.

7 Answers

Matt Campbell
Matt Campbell
9,767 Points

Sorry for taking so long getting this sorted for you but I've been flat out busy recently.

OK, here's the link to replace.php for WordPress: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

When I move a site I do this:

  1. Upload all the FTP I need with replace.php minus wp-config.php & export database to a safe place for import later.
  2. Run the WordPress install creating the database.
  3. Drop all the tables in the database and import earlier exported local database.
  4. Change wp_options url to reflect domain name.
  5. Run www.yourdomain.com/replace.php. In the search, search for the local address and replace with live address with no forward slash. Then hit back and repeat the search with forward slash at the end of the domain. EG. www.domain.com and www.domain.com/
  6. Go to admin and resave permalinks.

If you'd like me to break it down further, let me know.

Matt Campbell
Matt Campbell
9,767 Points

What are you doing when moving the files from your hard drive to your server? Are you moving the database and changing the wp_options table. You'll also need to rewrite the links in the files so it directs to the right file and not back to your hard drive using replace.php.

Mark Wardle
Mark Wardle
5,527 Points

This is my process:

  1. I go to MAMP's phpmyadmin, go to my database, choose export, and copy the mysql script it outputs. This first time I tried, I used a text editor to replace-all my localhost url with the launch site's url. The second time I didn't do this, because I used replace.php later on. I then went to my server's phpmyadmin page and ran the exported script as an sql query on the appropriate database.

  2. I FTP the site's files with a modified config.php file for the new DB, DB username, and DB password.

  3. The second time I tried, I uploaded replace.php and ran the script to replace localhost:8888 with my website's root url.

I'm putting the whole thing in a subfolder of my personal site, just so I have something to show the client. I'm using 'www.mysite.com/subfolder' as the replace string for 'localhost:8888'. I'm not sure if that makes a difference at all.

The site seems to be pulling the information from the database just fine, for the most part. It's also rendering the majority of the home page. However, I get the following error messages showing up on the screen:

In the header

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'my_register_fields' was given in mysiteroot/wp-includes/plugin.php on line 406

In the footer

Fatal error: Call to undefined function wp_footer_scripts() in mysiteroot/wp-content/themes/mahalohealingcenter/footer.php on line 24

Mark Wardle
Mark Wardle
5,527 Points

By the way, thanks for the reply. I would love it if you could let me know what I'm doing wrong.

I'm using the following plugins if it makes a difference:

  1. Advanced Custom Fields
  2. Custom Post Type UI
  3. bbPress
Matt Campbell
Matt Campbell
9,767 Points

Sorry I haven't got back to you sooner on this, my system has been out of action since Saturday and writing out lengthy posts on iPad sucks.

Give me 12 - 18 hours and I'll put some info up, I'm UK based and it's 1:15am...time for bed!

Mark Wardle
Mark Wardle
5,527 Points

Take your time. I appreciate it.

Mark Wardle
Mark Wardle
5,527 Points

Thanks Torbjörn. I just figured out that it's not my database...It's actually the advanced custom fields plugin that is messing things up. I did a fresh install of WP on my live site, and the errors started as soon as I activated the plugin. I am really not sure why...It works fine on my local environment.

Torbjörn Sjögren
Torbjörn Sjögren
Courses Plus Student 1,621 Points

Strange... Try to redownload and reinstall AFC. Never had any problem with AFC. And do try WP Migrate DB. Its a great tool ( and i´m not paid to say it ;-) ). Want to see how it works? Watch the video. http://deliciousbrains.com/wp-migrate-db-pro

Have you tried the AFC forum?

Mark Wardle
Mark Wardle
5,527 Points

It turns out I had some bad code in my functions.php file. I just deleted it and everything worked fine. I don't remember why it was there in the first place. What I don't understand is why it wasn't affecting my local site, but was on my live site. It could just be that MAMP was suppressing the error from displaying whereas my live server was not.

Thanks for all your help!

Matt Campbell
Matt Campbell
9,767 Points

Mark Wardle, I had something similar stressing me out for over day. A plugin broke after I did something I couldn't for the life of me work out what I'd done. De-bugged for hours and found I'd somehow given an element the same ID as one in the plugin and that was screwing it up. Don't even remember doing it, could have been a bad copy and paste, grabbing the wrong thing. Can be super frustrating.