In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to add articles in batches through the built-in function of WordPress, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
Recently, the business needs to add a large number of articles to the website in bulk. Adding articles manually will definitely kill me, so I started looking for ways to add them in batches. In fact, the relevant contents of the article are already in the local database. The first way I thought of was to import the data directly into the online library through the sql statement.
So I passed.
INSERT INTO target_table (key1, key2...) SELECT key1', key2'... FROM source_table
The data is inserted into the online table. When you open the page, it's all garbled. So, I set the code again before inserting, and there is still a problem.
Since I am not good at sql, I adjusted my strategy. By chance, I found a built-in function of WordPress, 'wp_insert_post'. Yeah, that's him.
So I exported the target data to php_array, then introduced it into my script and added it to the database through the wp_insert_post function.
Foreach ($php_array as $item) {$arg = array ('post_title' = > $item [' title'], 'post_content' = > $item [' content'], 'post_excerpt' = > $item [' excerpt'], 'post_type' = >' post', 'post_status' = >' public', 'meta_input' = > array (' meta_key' = > meta_value')) Wp_insert_post ($arg);}
In this way, articles are added in batches in a "legal" way through WordPress, and custom columns can be added to meta_input, which is great.
Thank you for reading this article carefully. I hope the article "how to add articles in batches through WordPress built-in functions" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.