WordPress에서 페이지를 올바르게 복제하는 방법(2가지 방법 포함)

게시 됨: 2022-09-23

WordPress 사이트의 각 페이지를 수동으로 복제하는 데 시간을 낭비하지 마십시오. 많은 페이지를 복제하려는 경우 WordPress에서 쉽고 시간을 절약하는 방법으로 페이지를 복제하는 2가지 솔루션을 보여드리겠습니다.

WordPress에서 페이지를 복제해야 하는 경우는 언제인가요?

때로는 WordPress에서 페이지를 복제하여 다른 콘텐츠를 보여주지만 페이지 레이아웃은 동일해야 합니다. 수동으로 수행할 수 있습니다. 즉, 템플릿과 메타 설명 및 제목 태그를 포함한 SEO 요소를 복사해야 합니다. 그리고 이 과정을 여러 번 반복하는데 시간과 노력이 필요합니다.

더 편리하고 시간을 절약하면서도 여전히 매우 효과적인 다른 솔루션이 필요한 경우 플러그인 또는 functions.php 파일을 통해 WordPress에서 페이지를 복제하는 것이 좋습니다. 오늘은 이에 대한 자세한 안내를 드리고자 합니다. 시작하자!

WordPress에서 페이지를 복제하는 방법

실제로 WordPress에서 페이지를 복제하는 두 가지 주요 방법이 있습니다. 첫 번째는 WordPress Duplicator 플러그인을 사용하여 이를 수행하는 것입니다. 또 다른 하나는 functions.php 파일에 코드를 추가하여 페이지를 복제하거나 게시물을 복제하는 것입니다.

그러나 목표를 달성하려면 플러그인을 선택하는 것이 좋습니다. 테마 파일 편집기에 코드를 추가하면 때때로 WordPress 사이트에 오류가 발생하고 모든 것이 복잡해집니다. 따라서 안전한 솔루션을 얻는 것이 좋습니다.

플러그인을 사용하여 WordPress에서 페이지 복제

솔직히 말해서 현재 시장에는 WordPress에서 페이지를 복제하는 데 도움이 되는 수많은 편리한 플러그인이 있습니다. 그러나 사용하기 쉽고 효과적인 두 가지 플러그인인 Yoast Duplicate Post와 Duplicate Page and Post를 소개하고자 합니다.

이제 WordPress 사이트에 Yoast Duplicate Post 를 사용하는 자세한 지침을 살펴보겠습니다.

  • WordPress 관리자 대시보드에 로그인 -> 플러그인으로 이동 -> 새로 추가 .
  • Yoast Duplicate Post -> 설치 및 활성화 를 찾으십시오.
  • 관리자 대시보드에서 페이지 열기 -> 모든 페이지 를 선택합니다.
  • 복제하려는 페이지를 선택하면 2개의 새로운 옵션이 있습니다: 복제새 초안 .
  • WordPress에서 페이지를 복제 하려면 복제 버튼을 클릭하기만 하면 됩니다. 복사된 콘텐츠가 포함된 새 페이지를 생성 해야 하는 경우 새 초안 옵션을 선택하겠습니다.

Wordpress에서 페이지를 복제하기 위해 복제 게시물을 요스트하기만 하면 됩니다.

현재 페이지를 복제하는 데 도움이 되는 또 다른 플러그인은 Duplicate Page and Post 입니다. 아래 단계를 따르십시오.

  • WordPress 관리자 대시보드에 로그인 -> 플러그인으로 이동 -> 새로 추가 .
  • 중복 페이지 및 게시물 검색 -> 설치 및 활성화 합니다.
  • 액세스 열기 페이지 -> 모든 페이지 .
  • 복사해야 하는 페이지를 클릭하면 복사 옵션이 나타납니다. 그것을 누르면 콘텐츠를 편집할 수 있는 새 초안을 사용할 수 있습니다.

Wordpress에서 중복 페이지 및 게시물을 사용하여 페이지 복제

Functions.php 파일을 사용하여 WordPress에서 페이지 복제

WordPress에서 페이지를 복제하는 두 번째 방법은 Functions.php 파일에 코드를 삽입하는 것입니다. 이를 위해 Appearance -> Theme File Editor -> Functions.php 를 엽니다.

Functions.php를 통해 Wordpress에서 페이지 복제

이제 functions.php 파일에 다음 코드 조각을 추가하여 WordPress에서 페이지를 복제할 차례입니다.

/*
* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
*/
function rd_duplicate_post_as_draft(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
wp_die('No post to duplicate has been supplied!');
}


/*
* Nonce verification
*/
if ( !isset( $_GET['duplicate_nonce'] ) || !wp_verify_nonce( $_GET['duplicate_nonce'], basename( __FILE__ ) ) )
return;


/*
* get the original post id
*/
$post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
/*
* and all the original post data then
*/
$post = get_post( $post_id );


/*
* if you don't want current user to be the new post author,
* then change next couple of lines to this: $new_post_author = $post->post_author;
*/
$current_user = wp_get_current_user();
$new_post_author = $current_user->ID;


/*
* if post data exists, create the post duplicate
*/
if (isset( $post ) && $post != null) {


/*
* new post data array
*/
$args = array(
'comment_status' => $post->comment_status,
'ping_status' => $post->ping_status,
'post_author' => $new_post_author,
'post_content' => $post->post_content,
'post_excerpt' => $post->post_excerpt,
'post_name' => $post->post_name,
'post_parent' => $post->post_parent,
'post_password' => $post->post_password,
'post_status' => 'draft',
'post_title' => $post->post_title,
'post_type' => $post->post_type,
'to_ping' => $post->to_ping,
'menu_order' => $post->menu_order
);


/*
* insert the post by wp_insert_post() function
*/
$new_post_id = wp_insert_post( $args );


/*
* get all current post terms ad set them to the new post draft
*/
$taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
foreach ($taxonomies as $taxonomy) {
$post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
}

/*
* duplicate all post meta just in two SQL queries
*/
$post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
if (count($post_meta_infos)!=0) {
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
foreach ($post_meta_infos as $meta_info) {
$meta_key = $meta_info->meta_key;
if( $meta_key == '_wp_old_slug' ) continue;
$meta_value = addslashes($meta_info->meta_value);
$sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
}
$sql_query.= implode(" UNION ALL ", $sql_query_sel);
$wpdb->query($sql_query);
}


/*
* finally, redirect to the edit post screen for the new draft
*/
wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_post_id ) );
exit;
} else {
wp_die('Post creation failed, could not find original post: ' . $post_id);
}
}
add_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );

/*
* Add the duplicate link to action list for post_row_actions
*/
function rd_duplicate_post_link( $actions, $post ) {
if (current_user_can('edit_posts')) {
$actions['duplicate'] = '<a href="' . wp_nonce_url('admin.php?action=rd_duplicate_post_as_draft&post=' . $post->ID, basename(__FILE__), 'duplicate_nonce' ) . '" title="Duplicate this item" rel="permalink">Duplicate</a>';
}
return $actions;
}


add_filter('page_row_actions', 'rd_duplicate_post_link', 10, 2);

마무리

요컨대, 위의 WordPress에서 페이지를 복제하는 두 가지 방법 중 하나를 수행하여 페이지 복제 시간을 절약합시다. 주제와 관련하여 문제가 있는 경우 지원을 받을 수 있도록 아래에 의견을 남겨 주시지 않겠습니까?

마지막으로 중요한 것은 저희 마켓플레이스에서 모바일 친화적이고 눈길을 끄는 수많은 무료 WordPress 테마를 제공하고 있다는 점입니다. 따라서 WordPress 사이트에 대한 새 테마를 가져와야 하는 경우 놓치지 마세요!