Drupal to Wordpress - Migrating Comments - wordpress

I have a Drupal 6.25 database that I'm trying to migrate to Wordpress (v3.4.1). I'm able to copy the content into Wordpress, but when it comes to comments, I seem to have trouble with converting the thread column (in Drupal comments table) to comment_parent (in Wordpress wp_comments).
Here's the code that I'm using (taken from a tutorial):
INSERT INTO `mywordpress`.wp_comments
(comment_post_ID, comment_date, comment_content, comment_parent, comment_author,
comment_author_email, comment_author_url, comment_approved)
SELECT DISTINCT
nid, FROM_UNIXTIME(timestamp), comment, thread, name,
mail, homepage, ((status + 1) % 2)
FROM mydrupal.comments;
The above doesn't work since Wordpress comment_parent is a BIGINT type while the Drupal thread column is a VARCHAR, with values such as 0a.01.03.00/,
How can these be transformed into Wordpress compatible values?

You can try this query (I've taken it from this tutorial):
UPDATE IGNORE wordpress.wp_term_relationships, wordpress.wp_term_taxonomy
SET wordpress.wp_term_relationships.term_taxonomy_id = wordpress.wp_term_taxonomy.term_taxonomy_id
WHERE wordpress.wp_term_relationships.term_taxonomy_id = wordpress.wp_term_taxonomy.term_id

Related

How do we reset the blog_id count in a WordPress Multisite

I've just cloned all my subsites (40) from one Multisite to another of my Multisite installations. I want to use this opportunity to clean-up/reset the blog counter in my old MU to start at 2 again. Currently the blog counter is at 64 even though i only had 40 subsites. I know its like a primary-key in the db and auto increments with every new subsite created. With all my deletions and tinkerings over the months its left lots of gaps in the indexing numbers. I've found the column 'blog_count' in the wp_sitemeta Db table in MySQL and it currently stands at 40, correctly but i can't believe its the only place that the count exists and don't want to risk mucking about with it. Could it be safely altered??
The next sub-site of the multisite is defined by the AUTO_INCREMENT value of the wp_blogs DB table. It defines the next blog_id primary key. We can find AUTO_INCREMENT in the Operations tab of the table in the phpMyAdmin. But we can't change it to less number than used in the table.
But we can export the wp_blogs table, change it with Notepad++, then delete the table and import the changed table. Actually, I guess we can do it with the whole DB and replace any wp_{old_index}_ to wp_{new_index}_.
The example.
Let's imagine we have sub-sites from index 7 and more. These are steps for changing wp_7_{tables} to wp_2_{tables} (it's the first after the root site):
Make a full backup.:)
Remove all unnecessary sites (for example
wp_8_, etc.). Remove tables with old prefixes too.
Use the Search tab and change all DB fields with wp_7_{filedname} to
wp_2_{filedname}. Because there are some important site's metas with field starting with wp_{n}_{fieldname}.
On the Operation tab rename all DB tables with wp_7_{tablename}
to wp_2_{tablename}.
Change the wp_blogs table increment to 3 (it's next after 2): export the table in the phpMyAdmin, edit it, delete the original, and import the changed table back. The table is small it will easy.
Done. Add the next site with index 3.

Where are the Yoast SEO titles and descriptions stored?

I'm managing a small directory website and I have set some generic titles and descriptions for my pages with Yoast SEO Plugin.
I'd like to duplicate them to every entry/page directly via the MySQL database. However, I cannot find it in the DB.
I didn't find it in wp_postmeta, wp_posts or wp_yoast_seo_meta.
That's why I ask: where does Yoast (v. 7.8) store the SEO informations that a user set?
So after some time, I figured out that the best way to find out where this data where stored was to dump the DB and look in that dump:
mysqldump -u wordpress --no-create-info --extended-insert=FALSE wordpress -p > dumpydump.sql
cat dumpydump.sql | grep "What you're looking for"
What you'll find is an row called wpseo_taxonomy_meta in table wp_options which contains every taxonomy SEO texts. It is saved as a PHP serialised value.
Be careful though that this is just for the SEO texts of the Taxonomies (e.g. Location, Feature, Category...). It doesn't apply to the SEO descriptions and titles of the posts themselves (these are stored in wp_postmeta with at least one row per post).
Yoast SEO Save Description and Keywords in wp_yoast_indexable Table. Where you can see column name description and keywords
just use this code, you'll get an array of all settings that Yeast SEO show under "Search Appearance" page. Including title, descriptions and all other settings.
$wpseo_search =get_option( 'wpseo_titles', $default = false );
Update your required field and save using the update_option() function of WordPress.
You can use this (for categories):
$wpseo_options = get_option( 'wpseo_taxonomy_meta');
$wpseo_options['category'][<the_category_id>]['wpseo_title'] = '... my title';
$wpseo_options['category'][<the_category_id>]['wpseo_desc'] = '... my description';
update_option('wpseo_taxonomy_meta', $wpseo_options, true);
It should work. Also, you should check the wp_yoast_indexable table for correct recordings.

Wordpress and plugins (inventor) where posts table is defined

I need to make some work with wordpress 4.9. The table prefix is defined as abc_ and some posts is exists in table abc_posts. But also tables abc_2_posts and abc_3_posts is exists. Site catalog is actually rendered from abc_2_posts. Where this is configured?
This is because you are using a multisite installation. Every site in the network will have a unique id assigned to it. Looking at the table name abc_2_posts the number 2 tells you that this table is used by the site with id 2.

Tag all Wordpress posts

I've been searching for hours, either for a plugin or some safe looking SQL to do this, but nothing seems to be exactly what I need...
I have a Wordpress site of approximately 32,000 posts, and we use various tags to help with administration on the back end (i.e. they're not visible on the front end or used for SEO, before anybody comments on too much usage of the same tag). About 30,000 of these posts include the tag 'new', but we need to now tag the remaining ~2,000 to match.
The WP administration panel isn't really up for the task - it would take somebody days to go through and apply a tag to 2,000 posts. Various plugins seem to exist but they don't really do what they claim in the descriptions. And the only SQL I could find that seemed helpful assumes that the tag is new and that I want to apply it to all posts in a single category. I suppose I could delete the existing tag (again, not a fun task with Wordpress' admin panel - it generally crashes after about 30 posts meaning somebody has to sit clicking the button over and over) and then run the SQL to apply a new.
Can somebody point me in the right direction please?
You could run a loop over all of your posts and use wp_set_object_terms() to add the desired tag:
http://codex.wordpress.org/Function_Reference/wp_set_object_terms
I had this problem today too. I tagged all of my posts with the following SQL. (Replace <prefix> with your DB prefix and "GlobalTag" with whatever you want your tag name to be.)
# create a term which will be your new tag
INSERT INTO <prefix>_terms (name, slug) VALUES ("GlobalTag", "global-tag")
# this is what defines the term as a Tag vs Category vs Video Category, etc
# only do this if you are creating the category through SQL, not the GUI
INSERT INTO <prefix>_term_taxonomy (term_id, taxonomy, count)
SELECT
(SELECT term_id from <prefix>_terms AS term WHERE term.name="GlobalTag") as "term_id",
"tag" as "taxonomy",
(SELECT COUNT(*) FROM <prefix>_posts AS posts WHERE (posts.post_status IN ("publish", "draft")) AND LENGTH(post_content) > 25) as "count"
# now tag every post with GlobalTag
INSERT INTO <prefix>_term_relationships
SELECT
id as "object_id",
(
SELECT term_taxonomy_id
FROM <prefix>_term_taxonomy AS term_tax
INNER JOIN <prefix>_terms ON <prefix>_terms.term_id = term_tax.term_id
WHERE <prefix>_terms.name="GlobalTag"
) as "term_taxonomy_id",
0 as "term_order"
FROM <prefix>_posts AS posts
WHERE (posts.post_status IN ("publish", "draft")) AND LENGTH(post_content) > 25
NOTE: you may want to tweak the posts query in here. This tags all posts that are published and/or drafts and that have content that is longer than 15 words.

How can one reset the post views on a specific Wordpress page?

How can one reset the number of post views in order to remove a specific page from appearing in the "Popular" pages Wordpress widget?
Late to the party, I know, but I needed to figure this out today, which I did. So in case anyone else needs to know (for reference, I'm running WordPress version 3.3.1):
Page views are stored in the wp_postmeta table with a meta_key of post_views_count. Here's the query I used to find the views of a single post:
SELECT * FROM 'wp_postmeta' WHERE 'meta_key' = 'post_views_count' AND 'post_id' = 1234
The query returned 2 results. I'm not sure why, but setting the meta_value of both to zero did the job for me.

Resources