Repository navigation
Specific post tag stripped from posts when using wp export #130
Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
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
swissspidy commentedon Jan 15, 2026
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.jackmcconnell commentedon Jan 15, 2026
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 --allresolves this. Not sure if this is something that may cause an issue also?swissspidy commentedon Jan 15, 2026
Ah, that might be it.
The Twenty Fourteen theme contains code to hide the
featuredtag from the the results when fetching terms, which would explain this behavior. You could use the--skip-themesglobal argument to work around this.jackmcconnell commentedon Jan 15, 2026
Thank you. I can confirm that
--skip-themesfixes the issue. Thanks for your help.