E
E
Evgeniy2020-07-26 19:33:51
PHP
Evgeniy, 2020-07-26 19:33:51

How to import subcategories via csv?

Good afternoon. I'm trying to finish the import plugin. Faced such a problem. The plugin creates a $categories variable. It is also passed to taxonomy.php and there the foreach method turns it into an ordinary category. I changed the plugin a bit. Using the wp_create_categories($category, $id) function, I tried to transfer the sub-category. It didn't migrate, and reported an error in post.php.
Please help solve the problem. I'm not looking for ready-made answers, what should I read in order to better understand the work of wordpress in this particular area? Any help will be glad)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2020-07-26
@azerphoenix

Hello!
Your end goal is not entirely clear. Are you writing a plugin and run into a problem, or do you need to import a csv file into your site?
If the second option, then use the Wp All Import plugin, it has functionality for importing nested categories. The same can be done using the WP REST API if you need to parse some data directly into the VI.


what should I read to better understand how wordpress works in this particular area?

Perhaps all the necessary information is stored in the VP code. You can look at wp-kama or at the office. WP website,
Here is the function you are using. If errors occurred, what errors occurred, what exactly are you transferring, in what form, etc.
https://wp-kama.ru/function/wp_create_categories
I changed the plugin a bit.

Apparently you are trying to edit someone else's plugin, and here, of course, bugs are inevitable. It's hard to say what's wrong without debugging...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question