Ticket #12180 (closed defect (bug): fixed)

Opened 2 years ago

Last modified 16 months ago

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: wpdavis

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

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

Change History

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

comment:1   ryan2 years ago

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

ryan2 years ago

comment:2   ryan2 years ago

Try that.

comment:3   ryan2 years ago

  • Status changed from new to closed
  • Resolution set to fixed

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

  • Status changed from closed to reopened
  • Version changed from 3.0 to 3.0.1
  • Resolution fixed deleted

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.

  • Status changed from reopened to closed
  • Version changed from 3.0.1 to 3.0
  • Resolution set to fixed

#14306 for 3.1.

  • Status changed from closed to reopened
  • Severity changed from normal to major
  • Cc wpdavis added
  • Component changed from Export to Import
  • Version changed from 3.0 to 3.0.1
  • Resolution fixed deleted

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);
  • Severity changed from major to normal
  • Status changed from reopened to closed
  • Resolution set to fixed
  • Version changed from 3.0.1 to 3.0
  • Component changed from Import to Export

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.