Delete Wordpress Post from my .csv URL list - mysql

I've got a .csv file with a list of URL I want to delete in my wordpress blog (about 3000 URLs)
Which is the faster way to delete it? I suppose a SQL query, or something like this...

Wise WordPress admins employ plugins for this kind of purpose, rather than hacking away at the MySQL database behind the WordPress installation.
This plugin https://wordpress.org/plugins/bulk-delete/ claims to accept a bunch of URLs to delete.
(Don't forget to back up your installation first.)

Related

How do I merge two Wordpress SQL databases in phpmyadmin?

I do not want to manually type in thousands of posts from my old website on the front end of my new website. I simply want to merge the database from the old into the new website in phpmyadmin. I'll tweak the tables to suit the new software afterwards.
I think there are only four tables that need to be merged for my purposes: wp_postmeta, wp_posts, wp_usermeta and wp_users.
The old website is still live, and the most recent post is post_id 28,556. So to be safe and neat, I want all my new website post ids to begin at 30,000.
I found this code which is sort of what I'm looking for, but not really: https://gist.github.com/jazzsequence/99dbee218c1b9a84df0d. This code simply adds +1 to every row, ignoring all associations with usermeta, users, post_ids inside postmeta etc. It cannot be used.
If you are unable to answer the question in it's entirety (it will help thousands of wordpress users if you do it properly), please tell me how to add 30,000 to every value in a given column. eg. If the column is called ID and the existing values are 1,2,4,9,13,24,25,26,28, then they would become 30001,30002,30004,30009,30013,30024,30025,30026,30028.
This might only partially answer the question as it might not allow you to do it manually, but actually I wouldn't recommend it.
People already worked on this export - import logic, tested it and wrote plugins for that. I would suggest to use them instead of trying to write it all over again yourself.
Just backup your databases and use plugins such as: https://wordpress.org/plugins/wp-exporter/
I would do a google search and find the best export / import plugin that does exactly what you want, there are many of them out there for free.
For the last part of your question, I think
UPDATE `table` SET `ID` = 30000+`ID`
should be enough.
So if you want to combine two MySQL databases in WordPress quickly and easily, then you should read my blog post: 8 Simple Steps to Merge Two WordPress MYSQL Databases
Here, we will stumble upon the eight simple steps that will help you merge two MySQL WordPress databases in a matter of few minutes.
Let’s begin the PROCESS:
Step 1: Create Two New WordPress Installs in a Sub-folder.
In case your old site is not hosted, then you need to get it setup and running either in a subfolder on your server or locally on your PC using MAMP. Also, set up two new installs of WordPress for two different purposes:
To host the old WP database that you want to import, and
To create an exact copy of your existing WP site.
Step 2: Log into the database of your old WP site
oldIf you want to log into your old site’s database, you need to emulate the following process:
Go to wp_users in phpMy Admin.
Change the password (if you know which account was the site’s admin)
Click Edit next to their name and enter the new password in the user_pass field.
Select the MD5 from the drop-down menu to the left.
And hit the Go button to get the things done.
Step 3: Install WordPress Export tool
exportInstalling the WordPress export tool is as simple as clicking a button. All you need to do is to go to the Tools, click on the “Export” button, and install WP’ export tool.
Step 4: Select data and download export file
downloadThis step is all about selecting certain data/sections that you want to export. It may include multiple files. Once selecting the desired files, you’ll need to click on Download Export File button.
Step 5: Log into your copy of current WordPress site
Under this step, you need to log into your copy of your current WordPress website.
Step 6: Install the WordPress Import tool
To install WordPress Import tool, you first need to go to the tools in your settings option and click on the Import option.
Step 7: Select “WordPress”
Step 8: Select the created data file and import it
If everything combines perfectly into the test copy of your WordPress site, you can freely import the data into your actual site.
There is a new plugin : Versionpress (https://versionpress.com/open-source/).
You should manually install this plugin in your two wordpress websites. this plugin create a .ini files and it can merge your 2 databases

Which tables in a Wordpress database need to be edited for migration to a new URL?

I have seen many questions related to database migration, but none which clearly state: When editing a database which of the tables do I actually need to edit?
As a force of habit I edit the entire mySQL database, and usually that works out. (However on occasion this can mess up URL left in user comments for instance.) However it would be good to know specifically which tables I actually need to edit in order to complete a migration correctly.
EDIT: I already understand how a migration works and which tool to use, and I have read the codex entry on migration. I am not having a specific problem migrating.
This is really more of a best practices question.
What I am looking for is a definitive list of what tables I can exclude from my search and replace. For instance I know that the basic URL info is in wp_options, I know that (some) image paths are stored in wp_postmeta. Basically I want to exclude every table I possibly can, while still preserving the site's widgets, images, settings, etc.
The only references that HAVE to change are in the wp_options table. One is the home url and the other is the siteurl. These will allow you to log into the admin and view the frontend. However, you will still have to update your permalinks and rewrite rules using the admin.
I would still suggest an automated solution, however. I use this tool to find and replace database references. It is specifically made for wordpress, but it will work for any database. It also will allow you to select which tables to update and will work with serialized strings so you should be able to avoid errors in the comments section.
Simply drop the file on the root of your wordpress install and run through the prompts. Make sure to deselect the wp_comments and wp_commentmeta tables. Also, make sure you remove the file on production as it presents a potential security threat.
UPDATE BASED ON COMMENTS
Other than the two spots above, there are several places in the database that URLs are stored. Most plugins will store their options in the wp_options table. Typically, plugins will also serialize the data to avoid a ton of queries. You can't simply change the URL in the serialized data however, because there are length references in the serialized string. So if your current URL is 15 characters long and the new one is 20, you need to update the URL and the string length too. If you don't, PHP will just ignore the value. I believe this is a security measure to avoid code injection.
For assets in the media section the URLs are stored in the wp_posts under the post type attachment. If you are hardcoding absolute links in your posts, you may need to parse those as well (if this is the case, you can probably just parse the entire table). If you are using any sort of custom field plugin or doing anything with post meta for URLs you are also going to want to go through wp_postmeta.
One other thing to mention is that some plugins will add their own database tables. These are obviously on a per case basis, but a good rule of thumb is to try running a query for "%http%" in any string columns to see if there are hardcoded URLs. Here is the query I will use:
SELECT * FROM `table` WHERE `column` LIKE '%http%'
Download the file from the following link http://interconnectit.com/products/search-and-replace-for-wordpress-databases/.
Put it in the root folder and access the file and follow the steps and replace the urls.
I have been using it for quite a long time without any issues.
Hope it helps!
Thanks

Add joint primary key to wordpress posts table

I am working out how to synchronize wordpress installations where both can be updated simultaneously, and both can work offline, then come online to sync.
I think the easiest way to sync posts between sites, is to include the site id in the primary key of the posts. Therefore, any post is identified by an incremental id and the id of the server location it was created from.
Is this possible to achieve with a plugin?
What dangers lie ahead if I pursue this path?
Is there a better, alternative way to achieve what I am trying to achieve?
It is possible in several ways:
- Write a stored procedure inside the first Wordpress installation's php files, that inserts the content into the other database when something is written to it. This one probably won't work offline.
- Write a function that compares the two databases at a schedule time using a simple sql query and creates a diff log. Then copies over the difference to the other database.
It depends why you need to do this, but if this works, I would recommend this solution:
- Keep one wordpress installation. Maintain one database, and connect to it from the other website to load the content. You can create your own SQL connection to it and load whatever content you need.
- Keep one wordpress installation, and use it's RSS feed to read the content and display it in whichever second website you need to do it in.
I can't imagine how a plugin would be of much help, especially keeping the databases in sync offline too. In my experience, its usually better to write your custom php scripts, rather than use a plugin so you can have a more direct control over the functionality.
Hope this helps.

Can a separate WordPress (same server) get posts from an existing one, but have different settings?

When developing WordPress themes for a site with a large amount of posts, how can I dynamically pull existing post data from the live version of the site onto my testing site? I already know about WordPress's export feature, but that's one-and-done, not dynamically queried.
Plan A:
Proposed Solution:
Create read-only user in live site's database
PRECAUTION: change test site's prefix from "wp_" to "test_"
Problems:
Settings (like current theme) on test site cannot be changed, thanks to read-only user
No posts found in "test_posts", even though I'd like it to search "wp_posts"
Is there an easier way or existing solution to avoid rewriting WordPress system files on the test site? I'd really rather not rewrite WordPress's database interface...
Similar: Linking themes across WP installations
just duplicate the DB, re-name and call DB in wp-config!

moving wordpress mu to another domain - sql statements

I'm assuming these instructions are for "normal" wordpress... will this work with wpmu or do i need to modify this? Is there anything i should watch for?
http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/
See Moving WordPress « WordPress Codex and WordPress Serialized PHP Search Replace Tool
The biggest issue you face is changing URLs in the database; and you will need to change these URLs in each of the individual databases that Multisite installs uses. Check out the find/replace tool linked above; it correctly deserializes/serializes data in the database. If you change URLs in a text database dump, or with SQL queries as in the link you listed in your question, you risk breaking data, such as theme options and widget settings.
1/09/2016 Note: WordPress MU doesn't exist anymore. MU was rolled into WordPress core in version 3.0.