Duplicating a page in WordPress can be a useful task, especially if you want to recreate an existing layout, preserve specific formatting, or quickly create multiple pages with a similar structure. Here’s a step-by-step guide to duplicating a page in WordPress, using built-in features, plugins, and coding methods.
Method 1: Duplicate a Page Using a Plugin
If you’re not comfortable with code or want a quick solution, plugins are an ideal way to duplicate pages. Here are two popular plugins:
- Duplicate Post by Yoast
- Step 1: Go to Plugins > Add New in your WordPress dashboard.
- Step 2: Search for Duplicate Post by Yoast and install the plugin.
- Step 3: Activate the plugin.
- Step 4: Go to the page you want to duplicate by navigating to Pages > All Pages.
- Step 5: Hover over the page you want to duplicate, and you’ll see options to “Clone” or “New Draft.”
- Clone: Creates a duplicate in your list of pages as a draft.
- New Draft: Creates a duplicate and opens it in the editor.
- Step 6: Once duplicated, edit the title and content as needed.
- Post Duplicator
- Step 1: Go to Plugins > Add New, search for Post Duplicator, install and activate it.
- Step 2: Go to Pages > All Pages, hover over the page you want to duplicate, and select Duplicate Page.
- Step 3: Edit the duplicated page’s title, permalink, and content as needed.
Both plugins support duplicating custom fields, taxonomies, and settings, which is helpful if your pages have complex customisations.
Method 2: Duplicate a Page Using the Block Editor (Manual Copy and Paste)
If your page content is relatively straightforward, you can manually duplicate a page using the WordPress Block Editor (Gutenberg):
- Open the Existing Page:
- Navigate to Pages > All Pages and open the page you want to duplicate.
- Copy All Content:
- In the Block Editor, click on the three vertical dots (Options) in the top-right corner.
- Choose Copy All Content. This will copy all the blocks from the current page.
- Create a New Page and Paste the Content:
- Go to Pages > Add New to create a new page.
- Paste the copied content into the new page by right-clicking and selecting Paste or by pressing
Ctrl + V
(Windows) orCmd + V
(Mac).
- Edit the New Page:
- Change the page title, permalink, and any specific content you want to modify. Then publish or save the page as a draft.
Method 3: Duplicate a Page Using Code (For Advanced Users)
If you have a custom theme or prefer not to use plugins, you can add custom code to duplicate a page:
- Open the Theme’s
functions.php
File:
- Go to Appearance > Theme Editor and open
functions.php
. Make sure to use a child theme to avoid losing changes with future theme updates.
- Add a Custom Duplicate Function:
- Add this code to
functions.php
:function duplicate_page_as_draft() { global $wpdb; if (! (isset($_GET['post']) || isset($_POST['post']) || (isset($_REQUEST['action']) && 'duplicate_post_as_draft' == $_REQUEST['action']))) { wp_die('No page to duplicate has been supplied!'); } $post_id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']); $post = get_post($post_id); if (isset($post) && $post != null) { $new_post = array( 'post_title' => $post->post_title . ' - Copy', 'post_content' => $post->post_content, 'post_status' => 'draft', 'post_type' => $post->post_type, ); $new_post_id = wp_insert_post($new_post); wp_redirect(admin_url('post.php?action=edit&post=' . $new_post_id)); exit; } else { wp_die('Page creation failed, could not find original page: ' . $post_id); } } add_action('admin_action_duplicate_post_as_draft', 'duplicate_page_as_draft'); function duplicate_page_link($actions, $post) { if ($post->post_type == 'page') { $actions['duplicate'] = '<a href="' . wp_nonce_url('admin.php?action=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', 'duplicate_page_link', 10, 2);
- Save the Code: Click Update File to save the changes.
- Use the Duplicate Link: Now, when you go to Pages > All Pages, you’ll see a Duplicate option under each page title. Click it to create a duplicate of the page.
Conclusion
Each method has its pros and cons. If you want a quick, plugin-based solution, Duplicate Post by Yoast or Post Duplicator will be your best bet. For simple pages, manual copy and paste may suffice, while the code-based method offers more control if you’re comfortable with PHP.
Remember to check your duplicated pages for broken links or unwanted content that might have carried over, and be sure to customise the title and URL of each duplicated page before publishing.
For more help, simply get in touch and I’ll be happy to assist.