Hot answers tagged

34

The Media Library lives in both wp_posts and wp_postmeta. wp_postmeta contains the image URL wp_posts contains an entry for each image insertion into a post, along with the post ID. Exporting and importing these 2 tables as SQL did not work for me - I received 'duplicate entry for key 7'... Exporting and importing these 2 tables as CSV did work, using "...


29

Select * from wp_posts where post_type = 'attachment'; Will return all the entries in the Media Library. After the execution, you can export the result table as SQL, or CSV, or any other portable data format you like. Remember, if you are not sure if the entries already exist in your database, use the INSERT IGNORE statement instead of INSERT. (This is ...


12

It is that simple for Wordpress too. I use the following to back up my WP sites: mysqldump -u <user> -p<pass> --quick --extended-insert <db-name> > backup.sql The mysqldump document gives the details on all the parameters. --extended-insert is quicker when updating a DB from a dump file and makes the dump file smaller. --quick makes ...


12

I had a very similar problem when I moved a WordPress Blog from a single WordPress installation to a Multisite installation with different domain names but same IP. I found out that the problem is the wp_http_validate_url function which drops the URL if the source IP is the same as the destination IP. You can add a filter wp_http_validate_url to prevent this ...


10

if you check the Wordpress importer plugin it is easy to implement this feature. But if you want the direct answer , here it is First of all, we need to copy the Wordpress importer plugin files to our theme directory. like this 1. themes/bootstrapguru_theme/inc/wordpress-importer.php 2. themes/bootstrapguru_theme/inc/parser.php you can find ...


8

Check out http://wp-cli.org/. It's fantastic and I've used the export capability multiple times. More information on wp-cli. WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser. You will most likely have to install wp-cli. You can find ...


6

Since the asker really doesn’t want to post the answer … someone has to do it: SELECT wp_users.ID , wp_users.user_email FROM wp_users LEFT JOIN wp_bp_xprofile_data ON wp_bp_xprofile_data.user_id = wp_users.ID, WHERE wp_bp_xprofile_data.field_id = 8 AND wp_bp_xprofile_data.value = 'yes' field_id = 8 being the Field you want to get (in my ...


6

This answer is essentially the same as Ünsal's, but I'd like to elaborate a bit because despite being right his answer didn't help me (I was just trying to remember what I'd done in the past, I should have read his more carefully and I would have figured it out, but I think for others a full description would be useful). To export the full category ...


5

Try this (you may need to bootstrap WP by loading wp-load.php, depending on where you put this code). $args = array( 'post_type' => 'post', 'post_status' => 'publish', //'posts_per_page' => -1 //uncomment this to get all posts ); $query = new WP_Query($args); while ( $query->have_posts() ) : $query->the_post(); $f = ...


5

Although Chip's method may work for some it did not for me. I did get it working however this way: Do the normal export of pages and posts and import them to your new blog (having deleted the original pages and posts) Download the wp-content/uploads folder via ftp from your old site and upload it to your new site, replacing what's there. Go into phpmyadmin ...


4

There are two basic approaches you can take. Use the standard wordpress inport / export plugin manually through the admin. Your custom post type must have the property can_export = true (default = true) If you go this route, there are interesting options for adding extra functionality for users, Check out this tutorial on adding export filters specific to ...


4

Unless there is a core Wordpress import filter available for your CMS ( see http://codex.wordpress.org/Importing_Content ) or a plugin for a CMS not covered by core WP ( see http://wordpress.org/extend/plugins/search.php?q=import ), or a Google search for your database schema doesn't reveal anything, you need to roll your own importer. The best way is to ...


4

The reason copying those messed up your site was probably because of id mismatches. That is, posts with the ids of the stuff you're importing already exists. Regardless, since woocommerce stores orders as a custom post type, your safest bet here is probably the built in wordpress post import/export tool. 1. In the wordpress backend for the old site ...


3

Putting the whole updated code. In your plugin update <form method="post" id="download_form" action=""> <input type="submit" name="download_csv" class="button-primary" value="<?php _e('Download the log (.csv)', $this->localizationDomain); ?>" /> </form> Now in your function.php add_action("admin_init", "download_csv"); ...


3

The start of what you're doing wrong can be explained by this quote: which action attribute points to a file (download.csv.php) in my plugin folder, that should not be shown, just prompt a file download dialog for the csv dump. and this code: $core = $_POST['download'].'wp-load.php'; if(isset($_POST['download']) && is_file($core)){ ...


3

A cursory search doesn't turn up any plugins that do this ... but you could use the built-in exporter as an example for building out your own plugin. It's located in /wp-admin/includes/export.php. Essentially, it's a PHP page that queries the database to get all of your posts, then dumps the content into a pre-build XML template that can be imported later.


3

Option 1 As the article linked by @MikeMadern suggests: in your web host control panel, go to PHPMyAdmin select the table wp_comments select Export, configure the format further down in the same screen, select the Save as file and Go Option 2 Or, as the same article suggests, just use a plugin: Export comments Pulls comments out of your WordPress ...


3

You guys give up too easily :) This worked for me: <?php require(dirname(dirname(__FILE__)) . '/wp-load.php'); require(ABSPATH . 'wp-admin/includes/admin.php'); require('includes/export.php'); ob_start(); export_wp(); $xml = ob_get_clean(); file_put_contents('out.xml', $xml); echo "done" ?>


3

The default exporter will do this. Instead of selecting "All Content", choose "Post" and then a category.


3

Problem is that meta values are not unique key/value data. E.g. with the key 'OneKey' you can have a lot of values for the same post. So, in a flat table, for the column 'OneKey' you should have multiple rows where the post id is the same and seems to me is not what you want. Sure, you can take ony one value treating all meta key as singular, but also a ...


3

You should probably not run preg_replace on the meta data for a _wp_attachment_metadata field as the data is serialized. I would recommend instead you write a small script to loop through the images, unserialize the data, update the value, serialize and store the modified array. Here's a sample function which does just that: function ...


3

The solution that we have gone with in the end uses a single call to get_user_meta passing just the $user_id - this way all user data is returned in a single query, reducing a heavy load on the DB during large user data exports. We then run a series of checks against the returned data - including: is_serialized( $value ) - to check if the data has been ...


3

You can consult this answer, but the instructions are a bit unclear, so I'll clarify them myself here. On the old blog, export the posts using the standard WordPress import/export functionality. If you're unfamiliar with that, see this link for more information: https://codex.wordpress.org/Importing_Content On the new blog, use the WP Importer to import the ...


2

If you have access to the database tables you can do a mysql dump export of the wp_term_relationships, wp_term_taxonomy, wp_terms tables and import those into the new wordpress installation. I just did this between two WP installs with over 300 categories and it worked fine.


2

I am definitely late to help out with my answer .. I hope :) , but I am aiming to anyone else who needs an updated WordPress function to export custom table to a nice and clean row display CSV file function ns_contact_form_csv_pull() { global $wpdb; $table = 'ns_contact_form';// table name $file = 'ns_contact_form_csv'; // csv ...


2

The GUID is not an URL. Use get_permalink() to get the correct URLs. Just ignore the GUID. It is – as the name says – an identifier.


2

To copy a WordPress install from A to B, do an SQL dump on site A, and restore it to site B. Then search and replace the DB to swap the old URLs for the new URLs. Make sure to copy over the uploads folder in wp-content. To do the search replace, consider using a tool such as this: https://interconnectit.com/products/search-and-replace-for-wordpress-...


2

Figured it out upon examining my SQL file. It begins as SQL, and near the end changes to PHP. For some reason the download got messed up and the SQL export began outputting the PHP of the PHPmyAdmin page I was on! (not even just the client side HTML, it was spitting out server side PHP). Anyways, my backup is corrupt. I had to restore from another database ...


2

The data for Currently Active Menus is not included in the exports (by default). This is because there is no guarantee the importing site will have the same theme (or same named menus). If changing the menus was a big deal, you could export/import all the data straight out of the database. (This option is strongly discouraged!)


2

The data in the options table is stored as serialized arrays. Use get_option() to get the data and unserialize them. array_walk( get_option( 'widget_text' ), function( $d ){ if ( ! empty( $d['title'] ) ) { printf( '<p>Title: %s<br>Text: %s</p>', $d['title'], htmlentities( $d['text'] ) ); } } ); If ...


Only top voted, non community-wiki answers of a minimum length are eligible