Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there anyway I could convert all the posts e have right now on our Worpdress install into products using some mysql query or something like that?

share|improve this question
    
Thank you for this... but, one also needs to convert the category type in the taxonomy table, otherwise the site gets a bit loopy! Transferring the tag type over as well is good too, if you used them. Once I also did that, categorised posts now = properly tagged and categorised products. :-) docs.woothemes.com/document/managing-product-taxonomies –  Nikki Sep 10 at 21:38

3 Answers 3

up vote 1 down vote accepted

You could install the Post Type Switcher plugin

Or Run SQL query on your database to change the post to product post type

UPDATE  `wp_posts` SET  `post_type` =  'product' WHERE  `post_type` = 'post';

Backup your DB 1st.

share|improve this answer

You can update the post_type in mysql table wp_posts update the post_type to product

sample query UPDATE wp_posts SET post_type = 'product' WHERE post_type = 'post';

share|improve this answer
1  
The correct post type is 'product' not 'products', otherwise excellent solution, you do not need a plugin for something so simple. –  deweydb May 7 at 2:09

Please use $wpdb to interact with the Database.

global $wpdb;
$wpdb->update(
    // Table name
    $wpdb->posts,
    // New values
    array( 'post_type' => 'product', ),
    // SQL "WHERE" clause base / affected rows
    array( 'post_type' => 'post', ),
    // Data Type (available: %s string, %d integer, %f float)
    '%s',
    // SQL "WHERE" clause Type
    '%s'
);

Keep in mind that this query will change the post_type of every post to product. Updating your DB before doing this is recommended. It would be even better if you use a (local) test installation and refine your update process there.

More info about updating rows in the DB.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.