{"id":1978,"date":"2023-11-08T13:00:49","date_gmt":"2023-11-08T12:00:49","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=1978"},"modified":"2023-11-08T13:58:56","modified_gmt":"2023-11-08T12:58:56","slug":"wordpress-duplicate-page","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/wordpress-duplicate-page\/","title":{"rendered":"How to Duplicate Your WordPress Pages or Posts"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]If you can\u2019t think of a single reason why anyone would need to duplicate their pages or posts in WordPress, you probably never had to redesign your site. If you did, you\u2019d know just how useful duplicating pages or posts can be. [\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this article, we\u2019re going to show you how to duplicate a page in WordPress,<strong> the benefits of creating duplicate pages or posts<\/strong> and teach you three ways to do it: manually, using a plugin and using code.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Here\u2019s what we\u2019ll discuss: [\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#why-and-when\">Why and When to Duplicate WordPress Pages or Posts? <\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#manually\">How to Duplicate a WordPress Page Manually?<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#using-plugin\">Duplicating Pages or Posts Using a Plugin<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#using-code\">Duplicating Pages or Posts Using Code<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"why-and-when\"><\/a>Why and When to Duplicate WordPress Pages or Posts?<\/h2>\n<p>[\/vc_column_text][vc_column_text]One of the most common situations in which WordPress users can benefit from duplicate pages or posts is when they want to revamp, refresh or overhaul an existing page, but they don\u2019t want to lose all its content. The same goes for posts, of course. It\u2019s an essential technique in <a href=\"https:\/\/qodeinteractive.com\/magazine\/ways-to-reuse-and-repurpose-wordpress-content\/\">repurposing old content<\/a>, and it\u2019s much better than the simple copy\/paste.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]\u201cWhat\u2019s wrong with copying and pasting the content in a new draft to use it again after you make the changes?\u201d you might ask. Well, of course, that would work but <strong>it would be pretty time-consuming<\/strong>, for one thing.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Also, and more importantly, <strong>it might affect all your previous SEO efforts<\/strong>, and, consequently, damage your page rank. This is because, when you simply copy the content and paste it on a page that you have redesigned, everything you\u2019ve done SEO-wise, as well as your featured image, page templates and other related data, would be lost.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Also, duplicate pages are useful for situations when you just want to <strong>tweak a few things in your page design<\/strong>, for example, and compare it with the old version to see which one works better. This is particularly handy for when you\u2019re redesigning your website and need to see how your content will fit your new design elements.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As you can see, there are many situations in which <a href=\"https:\/\/qodeinteractive.com\/magazine\/wordpress-duplicate-menu\/\">creating a clone<\/a> or a duplicate of your page or post comes in handy.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"manually\"><\/a>How to Duplicate a WordPress Page Manually?<\/h2>\n<p>[\/vc_column_text][vc_column_text]This will depend on the page builder you\u2019re using. For Elementor users, there isn\u2019t a single <em>Duplicate<\/em> feature as such, but what you can do instead is save your existing page as a template and then use it to create a new one that represents an exact duplicate.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In the page you want to duplicate, navigate down to the bottom left of the screen and click on the arrow to open the menu, where you will select <em>Save as Template<\/em>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"528\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Save-as-Template-Elementor.jpg\" class=\"attachment-full size-full\" alt=\"Save as Template Elementor\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Save-as-Template-Elementor.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Save-as-Template-Elementor-300x163.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Save-as-Template-Elementor-768x418.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Save-as-Template-Elementor-620x338.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]This will open a dialog box where you can give your template a name. It will be saved in the Elementor templates folder from which you can always access it and reuse it. [\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"528\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Elementor-templates-folder.jpg\" class=\"attachment-full size-full\" alt=\"Elementor templates folder\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Elementor-templates-folder.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Elementor-templates-folder-300x163.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Elementor-templates-folder-768x418.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Elementor-templates-folder-620x338.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Now go ahead and create a new Elementor page. Give it a title and then click ont he folder icon to access your saved template. [\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"528\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Access-your-saved-template.jpg\" class=\"attachment-full size-full\" alt=\"Access your saved template\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Access-your-saved-template.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Access-your-saved-template-300x163.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Access-your-saved-template-768x418.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Access-your-saved-template-620x338.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Navigate to the <em>My Templates<\/em> section, find the template you need and click on <em>Insert<\/em>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"528\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/My-Templates-section.jpg\" class=\"attachment-full size-full\" alt=\"My Templates section\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/My-Templates-section.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/My-Templates-section-300x163.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/My-Templates-section-768x418.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/My-Templates-section-620x338.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]And just like that, all the content, design and page settings will be recreated right there in your new page. [\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Now, as for Gutenberg, the process is similar, except you will be copying blocks. Access the page you want to duplicate and in the upper right corner of the screen click on the three dots. In the menu that opens, select <em>Copy all blocks<\/em>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"528\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Copy-all-blocks.jpg\" class=\"attachment-full size-full\" alt=\"Copy all blocks\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Copy-all-blocks.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Copy-all-blocks-300x163.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Copy-all-blocks-768x418.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Copy-all-blocks-620x338.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Now create a new page, give it a title and simply right-click and select Paste or press <em>Ctrl+V<\/em> and your copied blocks (design and content) will be pasted into the new page, which will be an exact duplicate of the one you copied.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Now, this is a method that works best for occasionally copying single pages or posts. It may not suffice for bulk actions and for more streamlined duplicating processes, which is why it\u2019s worth considering other solutions. [\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"using-plugin\"><\/a>Duplicating Pages or Posts Using a Plugin<\/h2>\n<p>[\/vc_column_text][vc_column_text]As is so often the case with WordPress, the most useful solutions come in the form of our little friends, the plugins. While there are several excellent plugins for duplicate pages and posts on the market, we can\u2019t possibly feature them all, so we\u2019re going to talk about the most popular one \u2013 <a href=\"https:\/\/wordpress.org\/plugins\/duplicate-post\/\" target=\"_blank\" rel=\"noopener noreferrer\">Yoast Duplicate Post<\/a>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Yoast-Duplicate-Post.jpg\" class=\"attachment-full size-full\" alt=\"Yoast Duplicate Post\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Yoast-Duplicate-Post.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Yoast-Duplicate-Post-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Yoast-Duplicate-Post-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]This is a neat, simple and functional plugin with over <strong>three million active installations<\/strong> that you can download and use for free.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you have installed and activated the plugin, go to your posts or pages, and you\u2019ll notice some new options appear as you hover above the post you want to duplicate. There will be two options: <em>Clone<\/em> and <em>New Draft<\/em>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post.jpg\" class=\"attachment-full size-full\" alt=\"Post options Clone and New Draft\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The <em>Clone<\/em> option creates <strong>the exact duplicate of the post you want to edit or change<\/strong>. The duplicate will appear on top of the list of posts and, clicking on it, you will be able to edit it the usual way.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-1.jpg\" class=\"attachment-full size-full\" alt=\"The Clone option\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-1.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-1-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-1-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<em>New Draft<\/em>, on the other hand, creates a clone of the page and then <strong>opens the page\/post editor right away<\/strong>. Once you\u2019ve made all the necessary changes to the post, click on <em>Publish<\/em> and review it live.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-2.jpg\" class=\"attachment-full size-full\" alt=\"New Draft option\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-2.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-2-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-2-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]And that\u2019s really all there is to it. Once you no longer need the clones, you can delete them quickly by clicking on the <em>Trash<\/em> link that reveals underneath the post upon hover.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-3.jpg\" class=\"attachment-full size-full\" alt=\"Delete post\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-3.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-3-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2019\/10\/Duplicate-a-Page-or-a-Post-3-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;79px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"using-code\"><\/a>Duplicating Pages or Posts Using Code<\/h2>\n<p>[\/vc_column_text][vc_column_text]While plugins are certainly of tremendous help in many situations, sometimes we want to get our hands dirty and get things done by ourselves, without resorting to a plugin. This may be because we want to test our knowledge and expertise or show ourselves that we can do it on our own. But more often it\u2019s because we already have dozens and dozens of plugins installed and we feel that installing a new one would weigh the whole thing down too much. [\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Either way, it is possible to duplicate a page or a post just using code. One GitHub user came up with a <a href=\"https:\/\/gist.github.com\/domantasg\/adfb4f3875aef743e86c48c7e5ca6a78\" target=\"_blank\" rel=\"noopener noreferrer\">neat function for creating duplicate posts or pages<\/a> that you simply need to copy to your <strong>functions.php<\/strong> file:[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">\/*\r\n* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen\r\n*\/\r\nfunction rd_duplicate_post_as_draft(){\r\nglobal $wpdb;\r\nif (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) &amp;&amp; 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {\r\nwp_die('No post to duplicate has been supplied!');\r\n}\r\n\/*\r\n* Nonce verification\r\n*\/\r\nif ( !isset( $_GET['duplicate_nonce'] ) || !wp_verify_nonce( $_GET['duplicate_nonce'], basename( __FILE__ ) ) )\r\nreturn;\r\n\/*\r\n* get the original post id\r\n*\/\r\n$post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );\r\n\/*\r\n* and all the original post data then\r\n*\/\r\n$post = get_post( $post_id );\r\n\/*\r\n* if you don't want current user to be the new post author,\r\n* then change next couple of lines to this: $new_post_author = $post-&gt;post_author;\r\n*\/\r\n$current_user = wp_get_current_user();\r\n$new_post_author = $current_user-&gt;ID;\r\n\/*\r\n* if post data exists, create the post duplicate\r\n*\/\r\nif (isset( $post ) &amp;&amp; $post != null) {\r\n\/*\r\n* new post data array\r\n*\/\r\n$args = array(\r\n'comment_status' =&gt; $post-&gt;comment_status,\r\n'ping_status' =&gt; $post-&gt;ping_status,\r\n'post_author' =&gt; $new_post_author,\r\n'post_content' =&gt; $post-&gt;post_content,\r\n'post_excerpt' =&gt; $post-&gt;post_excerpt,\r\n'post_name' =&gt; $post-&gt;post_name,\r\n'post_parent' =&gt; $post-&gt;post_parent,\r\n'post_password' =&gt; $post-&gt;post_password,\r\n'post_status' =&gt; 'draft',\r\n'post_title' =&gt; $post-&gt;post_title,\r\n'post_type' =&gt; $post-&gt;post_type,\r\n'to_ping' =&gt; $post-&gt;to_ping,\r\n'menu_order' =&gt; $post-&gt;menu_order\r\n);\r\n\/*\r\n* insert the post by wp_insert_post() function\r\n*\/\r\n$new_post_id = wp_insert_post( $args );\r\n\/*\r\n* get all current post terms ad set them to the new post draft\r\n*\/\r\n$taxonomies = get_object_taxonomies($post-&gt;post_type); \/\/ returns array of taxonomy names for post type, ex array(\"category\", \"post_tag\");\r\nforeach ($taxonomies as $taxonomy) {\r\n$post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' =&gt; 'slugs'));\r\nwp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);\r\n}\r\n\/*\r\n* duplicate all post meta just in two SQL queries\r\n*\/\r\n$post_meta_infos = $wpdb-&gt;get_results(\"SELECT meta_key, meta_value FROM $wpdb-&gt;postmeta WHERE post_id=$post_id\");\r\nif (count($post_meta_infos)!=0) {\r\n$sql_query = \"INSERT INTO $wpdb-&gt;postmeta (post_id, meta_key, meta_value) \";\r\nforeach ($post_meta_infos as $meta_info) {\r\n$meta_key = $meta_info-&gt;meta_key;\r\nif( $meta_key == '_wp_old_slug' ) continue;\r\n$meta_value = addslashes($meta_info-&gt;meta_value);\r\n$sql_query_sel[]= \"SELECT $new_post_id, '$meta_key', '$meta_value'\";\r\n}\r\n$sql_query.= implode(\" UNION ALL \", $sql_query_sel);\r\n$wpdb-&gt;query($sql_query);\r\n}\r\n\/*\r\n* finally, redirect to the edit post screen for the new draft\r\n*\/\r\nwp_redirect( admin_url( 'post.php?action=edit&amp;post=' . $new_post_id ) );\r\nexit;\r\n} else {\r\nwp_die('Post creation failed, could not find original post: ' . $post_id);\r\n}\r\n}\r\nadd_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );\r\n\/*\r\n* Add the duplicate link to action list for post_row_actions\r\n*\/\r\nfunction rd_duplicate_post_link( $actions, $post ) {\r\nif (current_user_can('edit_posts')) {\r\n$actions['duplicate'] = '&lt;a href=\"' . wp_nonce_url('admin.php?action=rd_duplicate_post_as_draft&amp;post=' . $post-&gt;ID, basename(__FILE__), 'duplicate_nonce' ) . '\" title=\"Duplicate this item\" rel=\"permalink\"&gt;Duplicate&lt;\/a&gt;';\r\n}\r\nreturn $actions;\r\n}\r\nadd_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );\r\nto join this conversation on GitHub. Already have an account? Sign in to comment<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;18px&#8221;][vc_column_text]You can do it directly on your server using an <strong>FTP client of your choice<\/strong>, but we suggest you simply use the <strong>WordPress file editor<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Note here that this code is written for <strong>duplicating WordPress posts<\/strong>. If you want to <strong>duplicate pages<\/strong> as well, you need to change the last line in the snippet so that, instead of \u2018post_raw_actions\u2019 it says \u2018page_raw_actions\u2019.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After you have entered the code in your functions.php file, go to your dashboard where your pages and posts are listed (All Posts or All Pages). If everything worked fine, there will be a new option available underneath each of the posts or pages, saying simply <em>Duplicate<\/em>. Clicking on it will create a clone of that particular page or post, just as it would if you were using a plugin.[\/vc_column_text][vc_empty_space height=&#8221;81px&#8221;][vc_widget_sidebar sidebar_id=&#8221;latest-themes&#8221;][vc_empty_space height=&#8221;80px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Final Thoughts<\/h2>\n<p>[\/vc_column_text][vc_column_text]As you can see, creating duplicate WordPress pages or posts is actually a piece of cake, whether you\u2019re doing it manually, using a plugin or opting for code instead. We are sure you\u2019ll find this option more than convenient in many situations. [\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Now that you know how to duplicate a page in WordPress, just remember to <a href=\"https:\/\/qodeinteractive.com\/magazine\/duplicate-content-in-wordpress\/\">clean up the unused duplicate posts<\/a> once in a while \u2013 clutter is never a good thing for a website. Also, if you intend to use code to duplicate posts, <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-manually-backup-wordpress-website\/\">make sure your website is backed up<\/a>, as it should be whenever you\u2019re editing WordPress files.[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>We\u2019re going to explain the benefits of creating duplicate pages or posts and we\u2019re going to show you two ways to do it: using a plugin and using code<\/p>\n","protected":false},"author":3,"featured_media":2111,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[21,15,13],"class_list":["post-1978","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-php","tag-plugins","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/1978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=1978"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/1978\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/2111"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=1978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=1978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=1978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}