Skip to content

Specific post tag stripped from posts when using wp export #130

Closed

Description

@jackmcconnell

Bug Report

Describe the current, buggy behavior

I have a post_tag with a name of 'featured' and a slug of 'featured-2'.
When running wp export --post__in="$(wp post list --tag="featured-2" --format=ids)" I get the correct output of posts as an XML file however, it doesn't have the 'featured' tag included with the posts. It is listed further up the file, as if it's expected to be used in the import, but this is the only time it appears.

If I export the posts using the WP Admin instead, the post_tag is correctly included with each post in the XML file output, and the output looks like this:
<category domain="post_tag" nicename="featured-2"><![CDATA[featured]]></category>
I understand the command is slightly different, as the UI doesn't provide a way to export tags, but it provide the desired output.

Describe how other contributors can replicate this bug

Create a post tag with a name of 'featured' and a slug of 'featured-2'.
Create a regular post with dummy title and content, and associated the 'featured' tag with it.
Publish the post.
Generate an export using this command: wp export --post__in="$(wp post list --tag="featured-2" --format=ids)"
Look at the resulting export XML file.
Do the same using WP Admin > Tools > Export and look at the resulting export XML file.

Describe what you would expect as the correct outcome

The XML file produced by the WP CLI wp export command should be the same as the one exported from the WP Admin.

Let us know what environment you are running this on

Shell:	/bin/zsh
PHP binary:	/Users/Jack/Library/Application Support/Local/lightning-services/php-8.1.29+0/bin/darwin-arm64/bin/php
PHP version:	8.1.29
php.ini used:	/Users/Jack/Library/Application Support/Local/run/p-d4viChN/conf/php/php.ini
MySQL binary:	/Users/Jack/Library/Application Support/Local/lightning-services/mysql-8.0.35+4/bin/darwin-arm64/bin/mysql
MySQL version:	mysql  Ver 8.0.35 for macos13 on arm64 (MySQL Community Server - GPL)
SQL modes:	
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar
WP-CLI packages dir:	
WP-CLI cache dir:	/Users/Jack/.wp-cli/cache
WP-CLI global config:	/Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/config.yaml
WP-CLI project config:	
WP-CLI version:	2.12.0

Activity

  1. swissspidy commented on Jan 15, 2026

    @swissspidy
    Member

    I tried reproducing this without look. See #131 where I added a test specifically following your instructions.

    The exported post contains <category domain="post_tag" nicename="featured-2"><![CDATA[featured]]></category> as expected.

  2. jackmcconnell commented on Jan 15, 2026

    @jackmcconnell
    Author

    Thanks. If it helps, the featured functionality was originally implemented to the TwentyFourteen theme and I've noticed that it doens't update 'featured' posts correctly on the front-end of the site if there are stale transients. Doing wp transient delete --all resolves this. Not sure if this is something that may cause an issue also?

  3. swissspidy commented on Jan 15, 2026

    @swissspidy
    Member

    Ah, that might be it.

    The Twenty Fourteen theme contains code to hide the featured tag from the the results when fetching terms, which would explain this behavior. You could use the --skip-themes global argument to work around this.

  4. jackmcconnell commented on Jan 15, 2026

    @jackmcconnell
    Author

    Thank you. I can confirm that --skip-themes fixes the issue. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions