[WordPress] 外掛分享: Large CSV Import Handler

首頁外掛目錄 › Large CSV Import Handler
10+
安裝啟用
★★★★★
5/5 分(1 則評價)
3514 天前
最後更新
問題解決
WordPress 3.0.1+ v0.9 上架:2016-08-05

內容簡介

這個簡單的外掛程式允許您從大型 CSV 檔案將任何類型的資料匯入到 WordPress 安裝中。

外掛程式會讀取 CSV 檔案,並透過 AJAX 請求一次一筆地匯入其記錄,因此不會有伺服器逾時的問題。

您只需要提供 PHP 函數,將 CSV 欄位值匯入文章或分類法語或其他所需內容即可。

使用範例:

例如,假設我們要從下列 CSV 檔案匯入文章:
title,text,brand,image
“Check this”,”Samsung content”,Samsung,”https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Samsung_Logo.svg/2000px-Samsung_Logo.svg.png”
“Some news”,”NewsHere are some news”,Philips,”http://www.underconsideration.com/brandnew/archives/philips_2013_logo_detail.png”

這裡有文章標題、文章內容、自訂欄位品牌和縮圖。

我們可以在主題的 functions.php 檔案中使用此代碼實現匯入功能:

add_action('lcih_import_csv_row', 'lcih_import_csv_row');
function lcih_import_csv_row($row)
{
$post_data = array(
'post_type' => 'post',
'post_status' => 'publish',
'post_title' => $row['title'],
'post_content' => $row['text']
);
$post_id = wp_insert_post($post_data);
if (!$post_id)
{
echo "Error inserting post.";
return;
}

update_post_meta($post_id, 'brand', $row['brand']);

if ($row['image'])
LargeCSVImportHandlerPlugin::download_post_thumbnail($post_id, $row['image']);

echo "Created post ".$post_id;
}

之後,我們可以進入外掛程式管理頁面,選擇要上傳的 CSV 檔案,然後點擊「開始匯入」按鈕。匯入流程將開始執行。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.9) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Large CSV Import Handler」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This simple plugin allows you to import any type of data from large CSV files into your wordpress installation.
Plugin reads CSV file and performs import of its records one by one through AJAX requests, so there are no server timeout issues.
You only need to provide PHP function to perform import of CSV field values into post or taxonomy term or whatever you need.
Usage example:
For example, assume we want to import posts from such CSV file:
title,text,brand,image
“Check this”,”Samsung content”,Samsung,”https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Samsung_Logo.svg/2000px-Samsung_Logo.svg.png”
“Some news”,”NewsHere are some news”,Philips,”http://www.underconsideration.com/brandnew/archives/philips_2013_logo_detail.png”
Here we have post title, post content, custom field Brand and thumbnail image.
We can use this code in theme’s functions.php file to implement import function:
add_action('lcih_import_csv_row', 'lcih_import_csv_row');
function lcih_import_csv_row($row)
{
$post_data = array(
'post_type' => 'post',
'post_status' => 'publish',
'post_title' => $row['title'],
'post_content' => $row['text']
);
$post_id = wp_insert_post($post_data);
if (!$post_id)
{
echo "Error inserting post.";
return;
}

update_post_meta($post_id, 'brand', $row['brand']);

if ($row['image'])
LargeCSVImportHandlerPlugin::download_post_thumbnail($post_id, $row['image']);

echo "Created post ".$post_id;
}

After that we can go to plugin admin page, select CSV file to upload and click “Start import” button. Import process will begin.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon