database - Exporting Post ID, Post Title, Primary Category and Primary Category ID

admin2025-06-02  1

Trying to export the following data from WordPress or directory through MYSQL query.

Post ID | Post Title | Post Content | Post Excerpt | Post Primary Category | Primary Category Term ID | Post categories | Category Term IDs

I have close to 115k posts in the database and close to 20k categories. Each post has multiple categories. So that's why I want one column to only have the primary category and the other column to list call categories.

I have tried all of the export plugins and the problem I run into is that I can not export "Primary Category Term ID" all in one file. I can get all the other fields, expect for category ID in the same file...I can do it seperatly, but I am trying to get it all in one file. It will save a lot of time.

I think the only way is to write a custom query that can export all the fields I need directly from mysql? is anyone here able to help me accomplish this?

Trying to export the following data from WordPress or directory through MYSQL query.

Post ID | Post Title | Post Content | Post Excerpt | Post Primary Category | Primary Category Term ID | Post categories | Category Term IDs

I have close to 115k posts in the database and close to 20k categories. Each post has multiple categories. So that's why I want one column to only have the primary category and the other column to list call categories.

I have tried all of the export plugins and the problem I run into is that I can not export "Primary Category Term ID" all in one file. I can get all the other fields, expect for category ID in the same file...I can do it seperatly, but I am trying to get it all in one file. It will save a lot of time.

I think the only way is to write a custom query that can export all the fields I need directly from mysql? is anyone here able to help me accomplish this?

Share Improve this question asked Feb 24, 2019 at 23:25 JDsJDs 1 2
  • 1 How are you storing primary category? That's not something WordPress does on its own. – Milo Commented Feb 24, 2019 at 23:49
  • Is "Post Primary Category" a custom taxonomy? – Qaisar Feroz Commented Feb 25, 2019 at 13:44
Add a comment  | 

1 Answer 1

Reset to default 0

Actually there is no primary category key. Usually, the first category is primary category by default. So technically, the below are the only fields I will need.

Post ID | Post Title | Post Content | Post Excerpt | Post categories | Category Term IDs

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748853079a314264.html

最新回复(0)