WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12180 closed defect (bug) (fixed)

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

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

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 4 years ago.
No posts for the custom taxonomies of a custom post type.
12180.diff (2.0 KB) - added by ryan 4 years ago.

Download all attachments as: .zip

Change History (10)

greenshady4 years ago

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

comment:1 ryan4 years ago

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

ryan4 years ago

comment:2 ryan4 years ago

Try that.

comment:3 ryan4 years ago

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

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

comment:4 ajferg4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 3.0 to 3.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.

comment:5 nacin4 years ago

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

#14306 for 3.1.

comment:6 wpdavis4 years ago

  • Cc wpdavis added
  • Component changed from Export to Import
  • Resolution fixed deleted
  • Severity changed from normal to major
  • Status changed from closed to reopened
  • Version changed from 3.0 to 3.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);

comment:7 wpdavis4 years ago

  • Severity changed from major to normal

comment:8 nacin4 years ago

  • Component changed from Import to Export
  • Resolution set to fixed
  • Status changed from reopened to closed
  • Version changed from 3.0.1 to 3.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.