In WordPress, duplicating a page means more than just copying and pasting the text written on it. You can also keep the page template, SEO information, and photos, thus saving you some time when editing the page. So, if you’re curious and want to find out how to duplicate a page in Word
Posted 4 années depuis in Voitures et Véhicules.
Over here, we’re going to talk about the plugins you can use for duplicating, so let’s jump right in.
One of the most common picks to achieve this is Yoast’s Duplicate Post plugin. With it, you can replicate comments, menu layouts, and, of course, duplicate a page. Furthermore, the plugin allows you to mark the title in order to differentiate between the original and the replica. Here’s how to use it:
You can choose multiple pages or posts, or you can use the Bulk Actions option to clone all of them at once.
Duplicate Page provides a few extra features that other cloning plugins don’t. It duplicates posts, pages, and custom post types.
In order to use this plugin, you’re going to need to do the following steps:
Furthermore, the created copies can be saved as a draft, pending, public or private.
Duplicating a page in WordPress is a great way to improve your workflow if you have an active blog or sales pages.
The Post Duplicator plugin lets you make an identical copy of a post/page in WordPress, fully with custom fields and classifications. It’s very easy to use because all you have to do is:
You can also customize the settings. Click on Tools ⇒ Post Duplicator and then choose the post status, the type and the date.
This WordPress Duplicate Page and Post allows you to do just that. This plugin is capable of duplicating a page /post without modifying the post type, content, title, or style.
Here’s how to use it:
The duplicated post/page will show up as a new version with the same name as the original.
Let’s see how you can make copies through the Block Editor and how you can duplicate a page in WordPress Elementor.
Inside the Block Editor, you can copy the whole post/page to your clipboard and paste it into a new one, and then… that’s that!
Here’s a quick recap on where you need to click:
Even though it’s not the most go-to method, it’s still an option and it does the job.
Sometimes you might need to replicate an Elementor post, page, or template, regardless of the type of site you’re managing.
Here’s a quick overview of how to make this happen:
Choose the template that you want to use and you’re done!
You probably wonder whether or not this is possible, and the answer is yes. Let’s take a look at how you can achieve that.
If you decide to go with this method, you should proceed with caution and create a backup of your site beforehand. To enable post cloning, navigate to your functions.php file and open it for modification. Then, at the bottom of the file, add the code from below:
| /* * 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( ‘post_row_actions’, ‘rd_duplicate_post_link’, 10, 2 ); |
To allow page cloning, use the same code but switch the last line from the code with:
| add_filter(‘page_row_actions’, ‘rd_duplicate_post_link’, 10, 2); |
After you’re done, save the file and re-upload it to your website. Then return to your WordPress dashboard. When you hold a mouse over a page /post you want to clone, a Duplicate button should now pop up.
You can do this if you don’t want to change your functions.php file. Follow these next few steps to do so:
As you might guess, this method might take you some time, so that’s why we’d suggest using a plugin that will do the job for you quicker and easier.
More WordPress Coverage: How to Change the Font in WordPress?
It comes in handy to know how to duplicate a page /post in WordPress. That’s why we hope you find our instructions and all the recommended tools in this article useful. Whether you’d like to do that manually or with a plugin – it’s up to you!
With the WordPress EA Post Duplicator Extension, you can easily clone any page/post type with a click. It can assist you with creating several posts rapidly or cloning page drafts for future editing.
Here’s how to duplicate a page in WordPress with this tool: