Make WordPress Core

Opened 17 years ago

Closed 16 years ago

#12180 closed defect (bug) (fixed)

Custom taxonomies for custom post types exported but not tied to posts

Reported by: greenshady Owned by:
Priority: normal Milestone: 3.0
Component: Export Version: 3.0
Severity: normal Keywords:
Cc: Focuses:

Description

Currently, the export tool exports custom post types and custom taxonomies. The problem is that each term isn't associated with its post after import into another WordPress setup.

I've created a "movie" post type along with several custom taxonomies for this post type: actor, producer, studio, writer, director, genre. I'll attach an image to give a clear view of what I'm talking about.

If anyone wants to tackle this, I have about 800+ "movies" and 1,000s of terms for those taxonomies for testing.

Attachments (2)

custom-post-tax-none.png (34.0 KB ) - added by greenshady 17 years ago.
No posts for the custom taxonomies of a custom post type.
12180.diff (2.0 KB ) - added by ryan 17 years ago.

Download all attachments as: .zip

Change History (10)

@greenshady
17 years ago

No posts for the custom taxonomies of a custom post type.

#1 @ryan
17 years ago

wxr_post_taxonomy() in wp-admin/includes/export.php needs custom taxonomy awareness.

@ryan
17 years ago

#2 @ryan
17 years ago

Try that.

#3 @ryan
17 years ago

  • Resolutionfixed
  • Status newclosed

(In [13055]) Export post <-> term relationships for all taxonomies. fixes #12180

#4 @ajferg
16 years ago

  • Resolution fixed
  • Status closedreopened
  • Version 3.03.0.1

This problem is still occurring in 3.0.1

I have custom post types (product) and custom non-hierarchical taxonomy (category). When I export, both Products and Categories are exported, but the products have no category association. I've checked the generated XML file, and taxonomy information is present for Posts, but not my custom Product post-type.

I'm not sure exactly how to submit a patch, but I think I managed to fix the issue in my local copy.

In /wp-admin/includes/export.php, there's a function wxr_post_taxonomy() about line 253

Replace this:

$taxonomies = get_object_taxonomies( 'post' );
$terms = wp_get_post_terms( $post->ID, $taxonomies );

With this:

$taxonomies = get_object_taxonomies( $post->post_type );
$terms = wp_get_object_terms($post->ID, $taxonomies);

The original code limits taxonomies to those associated with the 'post' post-type. This fix seeks taxonomies associated with whatever post-type this object may be.

#5 @nacin
16 years ago

  • Resolutionfixed
  • Status reopenedclosed
  • Version 3.0.13.0

#14306 for 3.1.

#6 @wpdavis
16 years ago

  • Cc wpdavis added
  • Component ExportImport
  • Resolution fixed
  • Severity normalmajor
  • Status closedreopened
  • Version 3.03.0.1

Sorry to open this back up again, but while the patch works for exporting correctly, the wordpress importer still doesn't read custom taxonomies. It only looks for tags on line 466.

preg_match_all('|<category domain="tag">(.*?)</category>|is', $post, $tags);

#7 @wpdavis
16 years ago

  • Severity majornormal

#8 @nacin
16 years ago

  • Component ImportExport
  • Resolutionfixed
  • Status reopenedclosed
  • Version 3.0.13.0

Hey William, since this was closed on a released milestone, generally we open up a new ticket. At this point, #14306 is already open for 3.1, with regards to exporting. Feel free to comment there.

The import process is entirely separate, so if that's your issue, then you should open a new ticket and we'll take a look.

Re-closing.

Note: See TracTickets for help on using tickets.