[web] xe에서 워드프레스로 이전하기
얼마전까지 사용하던 XE(XpressEngine)를 워드프레스로 옮기면서..
몇가지 사항을 정리해 두려고 한다. 뭐 또 사용할 일은 없겠지만.. 혹시나 다른사람에게 도움이 될까 하여.. ^^
우선 다음의 2가지 글을 참고하였다.
1. 먼저.. 글이동
insert into wp_posts (id, post_author, post_date, post_date_gmt,post_content,post_title,comment_count,post_status ) select document_srl, 1, regdate, last_update, content,title,comment_count,status from xe_documents;
원래 참고했던 글에서는 xe_documents의 nick_name필드를 wp_posts의 post_author에 넣는데.. post_author가 숫자 필드라.. nick_name이 들어가지 않는다. 나야 어치파 다 내가 쓴글이므로.. user_id “1”을 넣어줬다.
1-1. 공개/비공개 설정
update wp_posts set post_status='publish' where post_status='PUBLIC'; update wp_posts set post_status='private' where post_status='SECRET';
=======
170920 추가 : 아무래도 맘에 안들어서.. 좀 찾아봤더니 if구문을 쓰면 된다네. 1번쿼리와 1-1번 쿼리를 다음과 같이 하나로 해도 된다.
insert into wp_posts (id, post_author, post_date, post_date_gmt,post_content,post_title,comment_count,post_status ) select document_srl, 1, regdate, last_update, content,title,comment_count,if(status='PUBLIC','publish','private') from xe_documents;
=======
2. 카테고리
2-1. 카테고리 생성 : wp 관리자페이지(wp-admin)에서 카테고리를 생성해준다.
2-2. 카테고리 이동
query를 좀더 미려하게 짜서 한방에 해결할수도 있지만.. 난 카테고리가 2개밖에 되지않아.. 그냥 밀어넣고 업데이트 해줬다.
insert into wp_term_relationships select document_srl, module_srl, 0 from xe_documents; update wp_term_relationships set term_taxonomy_id=2 where term_taxonomy_id=58; update wp_term_relationships set term_taxonomy_id=3 where term_taxonomy_id=59;
앞에나오는.. 2,3은 새로 생성한 카테고리 아이디(wp_terms 테이블에서 확인), 뒤에나오는 58,59는 xe에서 쓰던 카테고리 아이디(xe_modules 테이블에서 확인)
=======
170920추가 : 역시 이것도 if문을 사용해서 하나의 쿼리로 변경 가능. 카테고리가 많아지면 이것도 귀찮아지겠네.
insert into wp_term_relationships select document_srl, if(module_srl=58,2,if(module_srl=59,3,module_srl)), 0 from xe_documents;
=======
3. 글 조회수
글별 카운트는 없다고 하길래 플러그인을 설치했다.
3-1. Page View Count 설치 -> 활성화 -> 설정에서 한번 save 해줘야 한다.
3-2. 만들어진 테이블에 조회수 이동
insert into wp_pvc_total(postnum,postcount) select document_srl,readed_count from xe_documents;
4. 댓글 이동
insert into wp_comments(comment_ID, comment_post_id, comment_author, comment_author_email,comment_author_IP, comment_author_url, comment_date, comment_date_gmt,comment_content) select comment_srl, document_srl, nick_name, email_address,ipaddress, homepage, regdate, last_update, content from xe_comments;
댓글 카운트 다시 해야된다는 글도 있었느나.. 나는 정상적으로 나온듯.
5. 글 슬러그 정리
글 슬러그를 그냥넣으면 안되고.. 인코딩해서 넣어야된다고 해서.. 원본글 참고하여 다음과 같이 실행
5-1. function.php 에 다음 코드 추가(보통 사용하는 테마 밑에 있다. 테마는 설치경로/wp-contents/thems/ 에 있다.)
add_action( 'the_post', 'wpse_94856_title_update' ); function wpse_94856_title_update( $post ) { if ( empty ( $post->post_title ) ) return; $temp_title = $post->post_title; $new_title = urldecode($temp_title); wp_update_post( array ( 'ID' => $post->ID, 'post_name' => $new_title ) ); // $post is passed by reference, so we update this property in real time $post->post_name = $new_title; }
5-2. 목록을 한번씩 출력해줘야 한단다.
5-2-1. wp관리페이지->설정->읽기->페이지당 보여줄 글의 수 : 충분히 크게(난 게시물이 400개 넘어서 500으로 잡았음)
5-2-2. 브라우저에서 글 목록 한번 불러옴
5-2-3. wp관리자페이지에서 “페이지당 보여줄 글의 수” 원상복구
5-3. fuction.php에 넣었던 코드 삭제
뭐 일단 이정도로 진행한듯 하다.
그뒤로.. jetpack 플러그인 추가(댓글 쇼셜로그인 기능), 구글통계 플러그인 추가 했다. 이건 나중에 기회되면 한번 더 써보던지..
여튼 그럭저럭 이전 완료했다..