website links with string auto attached - php

I made a new website for someone but when i tried to launch it live i had problems with links. The old version of the site had language extension.
Now every link with the domain:
sites.com get extension ( ex: www.site.com/**es**/; wwww.site.com/**en**/,www.site.com/**es**/contact)
Even thow i made dynamic links i have problems accessing the wordpressadmin and also i have problems with referencing the homepage from other pages (only way i was able to to refence the homepage was by making something like site.com#).
After every change in wordpress admin the links are adjusted with language extension/string.

To remove all language extensions you could run a query in the form:
UPDATE wp_posts
SET post_content = REPLACE(post_content, 'site.com/es/', 'site.com/')
WHERE post_content LIKE '%site.com/es/%'
On your database for each language extension. This will remove all references in post content. You'll also want to check your wp_options table, replacing finds in the option_value field.
Finally run a check on the wp_postmeta table - many items will be serialised values and so can't be changed with a simple find/replace like above. Instead you should run a find, then figure out how to change any found values via the Wordpress admin panel.
As always back up your database before playing around.

Related

Where does visual composer store links?

I am trying to target all links with no www. in the database.
https://launchhousing.org.au
and replace with
https://www.launchhousing.org.au
I have used the 'search and replace' plugin which has apparently changed all of the links but somehow Visual Composer seems to still have links without the www. I am using the VC 'Icon Box' and added in the URL field: http://launchhousing.org.au/category/policy-agenda/
Visual Composer store links in urlencode format as:
link=\"url:http%3A%2F%2Fsite.com%2Findex.php%2Fmembership-account%2Fmembership-levels%2F|||\"
That's why you can't find.
You need make sql dump of your database and make replacing:
http%3A%2F%2Foldsite.com%2F → http%3A%2F%2Fnewsite.com%2F
I hope this helps. Good luck.
You mean links that are in the page/post content? These will be in the post_content of the wp_posts table, along with the rest of the content. All the VC elements you put into a page/post are just shortcodes.
Though I also have found that plugins, such as WP DB Migrate seem to miss VC stuff in the post_content column.
I always have to manually do an SQL query. You can do this in phpmyadmin:
UPDATE wp_posts SET post_content = REPLACE(post_content, 'launchhousing.org.au', 'www.launchhousing.org.au')
And remember to change 'wp_posts' if your prefix is different.

Get custom tables from database in wp-config.php

I want to use another Wordpress installation that gets it's tables from my original Wordpress prefix. I installed both WP installations in the same database with another prefix. I use WP Event Manager and the original prefix is like this:
wp_em_events
I want the same plugin at my new installation to automatically get it's tables from the orginal one, like the following code already does for the users at my wp-config.php:
define('CUSTOM_USER_TABLE', 'wp_users');
Is there a rule I can use at my wp-config.php file like the one that gets the users? or is there another way to get the data from the orginal table to the new one?
Eventually it worked using the following code in wp-config.php:
define('EM_EVENTS_TABLE', 'wp_em_events');
It also works with other (Wordpress) tables:
define('POSTS_TABLE', 'wp_posts');
Pages are also seen as posts. Be sure to get al tables for a plugin, pages, users etc. . In some cases you also have to get the table with the meta information.

exporting database and wordpress theme not functioning properly

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

Wordpress DB structure

I want to create more pages in wordpress via running a script. I am new in wordpress and did not understand the wordpress db structure properly. Where I put the page name, link, image and other details?
Can u please tell me the db structure of wordpress?
Thanks in advance
The complete wordpress database structure here
page,link,image all or must be in posts table.
You can find that in wp_posts table. You should find it in the database you create it to install the WP for the first time.
Everything you need to know is here:
https://codex.wordpress.org/Database_Description
It even has links to old versions.
depending on what you might want to add you may have to add things to wp_posts and wp_postmeta, and possibly the taxonomy tables.

Where should I store global data for my multi-site WordPress plugin?

I wrote a plugin for WordPress which has a few user-configurable settings that are stored using WordPress's suggested method. I know they are saved in the wp_options table, but that is abstracted by the WordPress options API.
Now I'm trying to add a "global override" of the settings that can be configured in the Network Admin section of a multi-site installation. I found the appropriate hooks to design my settings page, however I can't find any info about where to save the data.
If I save it using the normal options API, then the settings get saved individually for each site. I'm looking for a place to save them globally for all sites, so the plugin can first look to see if the settings have been globally overridden by the server admin.
I can just write some code to write directly to the wp_options table of one of the sites (for example site #1) or even create my own table. I know how to do all of these things, but I don't want to do that if there's a preferred way to write mult-site plugins.
Thanks for any advice.
As you know the main deference between developing a single WordPress plugin vs. a multisite plugin is where data is written. According to this article since plugins normally have complete reign over one database, and in some cases the plugins local pages files you must be sure to only call the $wpdb global object instead of a hard-coded reference to a table.
For example, if you need to execute an SQL command on the posts table, then do not use wp_posts as the table name $post_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM wp_posts"));
use this
$post_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts"));
Please see the article for further info.

Categories