I'm editing a WP template in order to fit my requirements. I firstly installed WP on a temporary server and then moved (files + DB) to the new server (without reinstallation).
Now, I'm almost done, but sometimes it happen that the logo has changes, and some menu disappears. If I look at the database I discover that in 'wp_option' table, all value where url should be www.newserver.com reverted to the old www.oldserver.com
How does is this possible? How can I fix this? Is there something I should know before going on?
thanks
You can easily overcome this problem just go to
Dashboard-> settings-> general and replace wordpress address (url) and site address(url) with your domains url.
But prior to this setting you must change the value in wp_options table of option_name ->siteurl in database to your new siteurl or else it wont be possible for you to login into the dashboard of your site on server as unchanged siteurl will keep on redirecting you to localhost.
wordpress url shoud contain path to your wordpress folder whereas site address will be your domains name.
You came across this problem because you migrated your local's database onto the server and in the wp_options table the siteurl is still the same representing your local siteurl. This needs to be updated as mentioned above.
Wordpress stores the siteurl and address of wordpress folder in wp_options table to make functions like bloginfo ("siteurl")
to work properly and give you site address independent of changes.
Related
I have been setting up a WooCommerce store on an existing website and I have been having a problem where the Add to Cart button's form sends the user to a URL that begins with http, which gives an error in most major web browsers and is not processed by the server. The same occurs if you try to update any of the cart's settings, such as the address and the quantity of product in the cart.
I have tried the following:
changing the website URLs in the wp_options table in the database
using SSL plugins such as Really Simple SSL, which doesn't solve the problem
reinstalling the SSL certificate to force HTTP to HTTPS redirect
using WooCommerce's Force SSL setting to force HTTPS
overwriting the default cart templates, which does not work since the form action URLs are generated by PHP
I'm not sure what else to do to solve this. Any help with this would be greatly appreciated!
Few troubleshooting options to be followed :
Check whether you have changed the URL to https in two places and not just one ?
WordPress Address (URL) / WP_SITEURL: The address where your
WordPress core files reside.
Site Address (URL) / WP_HOME: The address typed in a browser to
reach your WordPress blog.
You mentioned in comment below the question that you face issue in updating the URL via dashboard. The reason may be that you might have hard coded the URL in config.php which overrides the dashboard settings which comes from db values.
Hard coding values of URL settings in the wp-config.php file makes you
lose the ability to modify them from the dashboard.
So, now if the above statement is true then proceed changing the values in config.php as follows
Edit your wp-config.php file.
Define your WP_HOME and WP_SITEURL settings by inserting these lines
towards the top:
define('WP_HOME','https://example.com');
define('WP_SITEURL','https://example.com');
In case if its already perfect then try changing these two values in db as follows
Navigate to wp_options table in phpmyadmin
Your wp_ prefix may differ depending on your installation settings.
Click edit beside either the siteurl or home entries.
You may need to search for them with the Filter rows function at the top.
Enter in your new value in the option_value field, then click Go
I want to run 2 wordpress sites, one.site.com and two.site.com from the same database. Everything remains the same except for the theme.
one.site.com - Existing site
two.site.com - Should use one.site.com's database except for the
theme
Is there any way this can be done ?
Since theme details are stored in wp_options table is it possible for two.site.com to use it to display a different theme ? Say duplicating that table and making two.site.com use it ?
I appreciate any help.
EDIT:
Both the sites do not have any plugins.
The solution below did the job for me,
Install 2 WordPress sites on a single database.
Create new table in your database. Call it wp_options2 and copy everything from wp_options into this new table
In second install go to wp-config.php, and before if (!defined('ABSPATH')) add define( 'M7_OPTIONS_TABLE', 'wp_options2');
In second install go to wp-includes/wp-db.php on line 1009 and add code:
if (isset( $tables['options'] ) && defined('M7_OPTIONS_TABLE')) $tables['options'] = M7_OPTIONS_TABLE;
These codes should be added in public function tables function, before if (isset( $tables['users']) && defined('CUSTOM_USER_TABLE')))
I found this solution here, https://wordpress.stackexchange.com/questions/84313/how-to-run-two-wordpress-blogs-with-different-themes-and-with-single-database-an#answer-175494
Since we use the same database, links will be same on both the sites. I had a lot of images linked and I removed them using
.single a[href$=".jpg"] {
pointer-events: none;
cursor: default;
}
You can run two sites from a single database but not from the same set of database tables as the stored data includes the site's domain name.
There are two values in the options table: siteurl and home which are used. Using the same options table won't work, even if you update options forcefully for each php run.
So you would need to use two databases.
EDIT:
My advice is to replicate base and run both sites on different databases.
This could probably be accomplished by using wildcard subdomains (https://codex.wordpress.org/Configuring_Wildcard_Subdomains).
It may be a little hacky, but you'd have to test the condition of your subdomain (maybe in wp-config.php?) and set the theme in the database (http://www.inmotionhosting.com/support/edu/wordpress/change-theme-in-db).
The only problem I could see with this is that your functions.php can change WP functionality, so a Parent theme with two Child Themes is probably a good idea(https://codex.wordpress.org/Child_Themes).
There is a lot of jiggery hackery regarding this question, but I think there's a fairly simple solution. First, ensure that both of your 2 sites have these hardcoded in wp-config.php:
define('WP_HOME', 'https://example.com');
define('WP_SITEURL', 'https://example.com');
These will help each site "override" whatever the database setting is for the URLs.
Next, decide which site is the MASTER site where you are going to be publishing new blog posts, making edits to site data, and such. On that site, activate the theme you want to use.
Now, go to your SLAVE site (I'm using these terms loosely) and delete that theme via SFTP, and upload whichever other theme you want to use on that site. Then, hardcode it like this:
define('WP_DEFAULT_THEME', 'twentytwenty');
In this way, the SLAVE site tries to find the correct theme from wp_options that is activated on the MASTER site but you deleted it already, so it reverts to using the default theme as defined in wp-config.php
Going forward, do not mess with site settings/plugins/etc on the SLAVE site, and make any changes to the design of your SLAVE site using the theme files only (like a static theme). Obviously if you are using a bloated theme and page builder type of situation that need MySQL, this isn't going to work...
Note: you may need to visit /wp-admin/themes.php on your SLAVE site at least once, to "force" WordPress to load the hardcoded theme.
If anyone is interested, SlickStack supports this approach.
Duplicate of https://wordpress.stackexchange.com/q/65560/wp-multisite-load-content-from-site-x-on-site-y
One might argue that using WP multisite-network functionality and adding a couple of documented API calls to ones theme could be a cleaner solution than manually modifying the database schema and messing with how WP access it.
For development purpose, I have duplicated the live instance files in a separate sub domain with different database. I modified the path the sub domain and .htaccess file including the database table setting changes. Everything works perfectly for the sub domain blog, However when I tried to access
http://dev.mysite.com/wp-admin
it is redirecting to
http://www.mysite.com/login?redirect_to=http%3A%2F%2Fdev.mysite.com%2Fwp-admin%2F&reauth=1
So the admin panel moving to root site admin.
I unable to find out which settings I missed out.
Any help/clue is much appreciated.
WordPress hardcodes your hostname several places in the database, including 'siteurl' and 'home' in the wp_options table. This can cause trouble if you forget to update some of them when you are moving your site.
I run these queries whenever I move or copy a WordPress install:
# update wp_posts set guid = replace(guid, 'old.com', 'new.com');
update wp_options set option_value = replace(option_value, 'old.com', 'new.com');
In a production setting, the guid of posts should not change. In a development setting, when the new site is on your local machine, it sometimes makes sense to uncomment that first line.
Take a look at the wp_options table in your database and make sure the siteurl value is set to http://dev.mysite.com/.
You can either use phpMyAdmin or if you have access to the database directly, you can view your option by:
select * from wp_options where option_name='siteurl';
And change it via:
update wp_options set option_value='http://dev.mysite.com/' where option_name='siteurl'
I'm to get migrate a website I populated for a friend from my server to his. Unfortunatly, the migration process isn't working the way it normally should.
Does anyone have an idea to what would cause this wordpress site to break and for all the navigation to direct to the original site?
Even my wp admin redirects to orginal page
Here's the site I hosted it on for demo: http://www.designobvio.us/avproduktor/
Here's the site I'm trying to migrate it too http://avprodukter.com/
I have no idea why avprodukters isnt working: steps I took.
Exported database from designobvio.us/avproduktor
Replaced all links with designobvio.us to avproduktor
imported database to http://www.avprodukter.com/
installed wp and now i'm here
I'm going to repeat this process again to see maybe I was just dumb
Wordpress has some special steps you have to take when migrating it to a different domain. Namely, you have to change the Blog URL from the administrative interface prior to moving the site.
There is a reference in the database to the old domain and that is what it is using to build the URL's. Without starting over, you can use a tool like phpMyAdmin, or even the MySQL console to change that setting in the database.
The two settings you would have to change in the database are in the wp_options table (assuming tables are prefixed with wp_). The two option_names are siteurl and home. Both of those should contain the old domain; you need to update them to reflect the new URL.
See Moving Wordpress from the Wordpress Codex for the full directions and steps to take in different scenarios.
You could start over and follow the steps from the link above, or you can just change those 2 values in the database and then you should be set.
Replaced all links with designobvio.us to avproduktor...
How did you do that? In phpmyadmin? If by a text editor with a database dump, you broke some serialized data. Use the queries below.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com/','http://www.newdomain.com/');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com/', 'http://www.newdomain.com/');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/');
And did you reset permalinks?
See Moving WordPress « WordPress Codex and How to Move WordPress Blog to New Domain or Location » My Digital Life
I've got a Wordpress site on our home intranet that has run into trouble now that the IP address has changed - The index page loads, but not the CSS and I can't log in to the site administration panel.
Unfortunately I am a bit behind on backups. Is there a way to get Wordpress to refer to the new IP address?
You have two places to update this (well three, but we'll stick with the two).
If you can still log into your admin section, type the following for your URI /wp-admin/options.php - so for example, if your site is http://localhost then your full URL will be http://localhost/wp-admin/options.php. Once you've logged into your site you should see two fields (well you'll see a lot of fields), but you'll want to look for the two with URL's in them - the Site URL and the Blog URL (in WP 2.7 the fields are labeled "home" and "siteurl", not sure on the other versions).
Or, you can log into MySQL database and run the following.
Select * from wp_options where option_name IN('siteurl','home');
I just ran this today on one of my installs. If you're option_value is set to your localhost - you can then run the following:
update wp_options set option_value='http://www.yourblogname.com' where option_name = 'siteurl';
update wp_options set option_value='http://www.yourblogname.com' where option_name = 'home';
This should update your table structure.
You have to change the 'home' and 'siteurl' in the settings. Since you cannot open the admin side of wordpress, open the database in phpMyAdmin(or something similar).
The options can be found in the 'wp_options' table(wp_ prefix might be different). Find the necessary setting using this query...
SELECT * FROM `wp_options` WHERE `option_name` IN ('siteurl', 'home')
Change the values of both the options to the new IP.
To temporarily be able to login, use this code in your wp-config.php:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
or you can add this to your theme's functions.php:
update_option('siteurl','http://example.com/');
update_option('home','http://example.com/');
Warning: Updating the SQL database will be required in order for installed plugins to use the new URL/hostname. So if you use plugins modifying the database is required.
I ran into this problem before when I was migrating a site from test to production. Conveniently, MySQL has a string replace function.
Try something like this:
UPDATE wp_posts SET post_content = REPLACE(post_content,"http://localhost","http://www.myblog.com")
I ran into this problem once. Loginto your DB and check your wp_options (if wp_ is your table prefix) and then search for all records and replace your old ip with new.
Possible columns to have the old ip would be 'permalinks' etc.. Sorry I cant see my blog's table structure now otherwise I would have posted the correct column name.
Be careful for the link: https or http !!
in the command line:
mysql -u root -p
in the SQL, set new IP for xxxx
mysql> use wordpress;
mysql> select * from wp_options where option_id=1;
mysql> update wp_options set option_value="http://xxxx" where
option_id=1;
exit
Restart server
Possibly WordPress.org's coverage of this issue was not available at the time the other answers here were written, but as of now I find it more complete and easier to follow.
In my case, the method of modifying wp-config.php was only partially successful. The Relocate method described in the above web page ultimately succeeded.
Here is a synopsis of WordPress.org's coverage:
1 Changing the Site URL
1.1 Edit wp-config.php
1.2 Edit functions.php
1.3 Relocate method
1.3.1 Code function
1.3.2 Steps
1.4 Changing the URL directly in the database
2 Moving Sites
2.1 Altering Table Prefixes
2.2 Changing Template Files
2.3 Changing the Config file
2.4 Verify the Profile
2.5 Changing the .htaccess file
2.6 Additional items of note
2.6.1 Important GUID Note
2.7 Multi-site notes
2.8 wp-cli