I am using https://github.com/proteusthemes/one-click-demo-import to create a one click demo import for my theme, however, when i click the button to import the demo data which i have exported via WordPress, the pages that use the custom post type categories with an ID of 9 stop working because when the demo data get imported the categories change their ID to 20 or something.

There are no other categories with same ID and its done on a fresh WP install.

What can cause this issue where when you import the demo data:

<wp:term>
    <wp:term_id><![CDATA[9]]></wp:term_id>
    <wp:term_taxonomy><![CDATA[slider_category]]></wp:term_taxonomy>
    <wp:term_slug><![CDATA[fullscreen_slider]]></wp:term_slug>
    <wp:term_parent><![CDATA[]]></wp:term_parent>
    <wp:term_name><![CDATA[fullscreen_slider]]></wp:term_name>
</wp:term>

the terms have their ids changed?

1 Answer
1

AFAIK, when a new term is imported, it will get an arbitrary ID, similar to posts. If all you need is a term attached to some posts, then it’s fine, because WordPress handles that automatically.

However, if you use the term ID somewhere else, like in the Customizer, you can’t get the new term ID.

I’d suggest you should not rely on the term ID. Why not using term slug? It’s not kind of 100% unique, but in most cases, it remains the same when you import. And you can easily get the term via get_term_by.

Leave a Reply

Your email address will not be published. Required fields are marked *