.htaccess - Wordpress get_template_directory() working on localhost and dev server with same database -


I want to develop locally on the local host, then press everything on a test server. Both the localhost and my test server are using the same database. The only problem is get_template_directory () returns to my test server path.

Can I use .htacess or something else to get back to the local / live path associated with get_template_directory ()?

<

I use the difference of the method suggested by Mark Zuckith in my establishment.

The idea is to have the following at the top of your wp-config.php file:

  if (file_exists (dirname (__FILE__). '/local-config.php ')) {Include (dirname (__FILE__).' /local-config.php '); Define ('WP_LOCAL_DEV', true); Return; }  

You can create a local-config.php file that can be used to specify different settings for local development. Unless you add this file to your source repository, then when you deploy on the stages / production server and the standard wp-config.php file will be used instead of the settings.

You can then filter by WP_LOCAL_DEV constant state, or you can specify individual constants in the local config files, such as

  define (' WP_CONTENT_DIR ', actual path ($ _ server)' DOCUMENT_ROOT ']). '/ Wp-content'); Define ('WP_CONTENT_URL', '/ wp-content'); Define ('WP_PLUGIN_DIR', actual path ($ _ server ['DOCUMENT_ROOT']). '/ Wp-content / plugins'); Define ('WP_PLUGIN_URL', '/ wp-content / plugins');  

Hope that helps.


Comments