$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>database - Exporting Post ID, Post Title, Primary Category and Primary Category ID|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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

Post a comment

comment list (0)

  1. No comments so far