Labs, WP Tricks

3 Ways To Import WordPress Multi Posts

Problem: I created lists with {CityName} and {Departments of City} two column in Excell. Cities are categories and departments of city will be as post. How can easily I add […]

yzr: Hakkı Cengiz
A+ A A- okuma

Problem: I created lists with {CityName} and {Departments of City} two column in Excell. Cities are categories and departments of city will be as post.
How can easily I add as post to Custom Meta Field {departments} in WordPress?

CityName Departments of City
Adana Adana Kozan Tech Office
Adana Adana Saimbeyli Tech Office
İstanbul İstanbul Kadıköy Tech Office
... ... ... Tech Office

 

Solutions

Hard Way

Of course the first thing that comes to mind making a new custom page template. In that page,

 


<?php 	
   $departments = array(
	array(
	   "title" => "Adana Kozan Tech Office", 
	   "cityid" => 153 // or city_nicename 
	),
        ...
  );
	foreach($departments as $c) {
		$istname = $c['title'];
		$cityid  = $c['cityid'];
		$station_info = array(
			'post_title' 	=> wp_strip_all_tags( $istname ),
			'post_content'  => wp_strip_all_tags( $cityid" ),
			'post_type' 	=> 'departments',
			'post_category' =>  array($cityid),
			'post_status' 	=> 'publish',
		);
		
		wp_insert_post($station_info);

	}
?>

This was hard way for me. Because little complicated and I saw critical errors. And I couldn't, It didn't worked. So if you could this way, please don't hesitate to say in comments where I made a mistake.

Middle Way

I thought "how the hell we export posts, that way we import". So I added two dummy department with city category. And exported to pc. And I thought of editing that complicated .xml file. But when I was thinking about it, I found a better way.

Easy Way

WP All Import plugin. Yes.

1. We are preparing in Excell. Then we save it as a .csv extension.
2. We also open it with notepad ++ and convert it with Encoding> Convert to UTF-8 and save it.
3. We enter the WP All Import plugin and determine how to drag it from there step by step, category, content, and which part to add. Next next. Finish 🙂

Good luckies 🙂

0 Yorumları: - Yorum Formunu: -

Henüz yorum eklenmemiş.

Bi yoruma ne dersin ?

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir