WPCode Logo

WPCode Blog

Everything you need to know about the WPCode plugin

How to Duplicate a Post or Page in WordPress (Free, No Extra Plugin) 

How to Duplicate a Post or Page in WordPress (Free, No Extra Plugin)  

TL;DR:

Install the free WPCode plugin. Go to Code Snippets » + Add Snippet, search for “duplicate,” and add the Duplicate Post/Page Link snippet. Switch it to Active and click Update. A Duplicate link now shows under every post and page. Click it to get a draft copy, then fix the title and URL before you publish.

Most sites have a few pages they build more than once.

Say you ran a Black Friday sale last year. The page already has the layout, images, and categories you set up, and this year you just want it back with new dates.

WordPress doesn’t have a button for that. You can copy the words into a new page, but the featured image, the categories, and any custom fields stay behind.

So you end up rebuilding half the page by hand.

In this article, we’ll show you how to add a Duplicate link to every post and page with one free snippet.

You won’t need a separate duplicator plugin. If you already use WPCode, there’s nothing new to install. If you don’t, WPCode is one free plugin that handles this snippet and any others you add later.

We’ll also show you exactly what the copy keeps, and what to fix before it goes live.

Key Takeaways

  • One free WPCode snippet adds a Duplicate link to your posts, pages, and most custom post types.
  • The copy is saved as a draft, so nothing changes on your live site until you publish it.
  • Content, featured image, categories, tags, and custom fields come along, while the author and date reset to you and today.
  • Before you publish, rename the “(copy)” title and set the URL yourself.
  • Don’t want a library account? You can paste the same code into a blank snippet instead.

What Copy and Paste Misses in WordPress

Copy and paste only moves the words. WordPress even has a shortcut for copying them, but it has the same gap.

To use it, open the post, click the ⋮ menu at the top right, and choose Copy all blocks under Tools. You can see where it sits in the screenshot below.

The block editor Options menu open, with Copy all blocks listed under Tools
The Copy all blocks option in the block editor’s Options menu.

That copies everything inside the editor, so you can paste it into a brand-new post.

But the settings around the content don’t come with it. The featured image, categories, tags, custom fields, and the page’s parent all have to be set again.

And WordPress doesn’t include a Duplicate button for posts and pages that copies those for you.

Most people add code like this through their theme’s functions.php file. That works, but a mistake in the file can break your site, and the code can be lost when you switch or update your theme.

WPCode gives you the same Duplicate button without putting the code in your theme files.


How to Duplicate a Post or Page in WordPress

We’ll use WPCode for this. Every step below works in the free version, called WPCode Lite. Check this WPCode review to see everything this code manager plugin can do.

Use the table of contents below to skip to the step you want to read.

Step 1: Install WPCode (Free)

WPCode is a code snippet manager that lets you add small pieces of code to WordPress without editing your theme’s files.

If a PHP snippet ever causes an error, WPCode’s error handling can switch it off rather than leave your site broken. This makes it safer to make changes like these.

To install it, go to Plugins » Add Plugin in your dashboard and search for WPCode.

WPCode plugin card showing logo, title, description and an Install Now button on a WordPress plugin marketplace search results page.
Find WPCode in your WordPress repository and install it.

Install and activate it like any other plugin. You’ll then see a new Code Snippets menu in your dashboard.

Step 2: Add the Duplicate Post/Page Link Snippet From the Library (Free)

Next, go to Code Snippets » + Add Snippet, which opens on the Snippet Library tab. That’s WPCode’s library of ready-made snippets.

Type “duplicate” into the search box on the left. Then hover over Duplicate Post/Page Link and click Connect to library to unlock (Free).

You may also see a Connect to Library banner lower on the page. It does the same thing as the Connect to library to unlock (Free) button on the snippet card, so you can use either one.

Here’s what the card looks like before your site is connected.

Panel titled 'Duplicate Post/Page Link' with a blue 'Connect to library to unlock (Free)' button
The Duplicate Post/Page Link snippet before the site is connected to the WPCode Library.

Once you click either option, WPCode opens a window where you can connect your site to the free WPCode Library.

Fill in your name, a username, your email, and a password, then click Register.

Already have a WPCode account? Click Already have an account? Login at the top of the window instead.

WPCode signup form with fields for first name, last name, username, and email; includes a link: Already have an account? Login.
The free WPCode account form that opens when you connect your site to the library.

After you register or log in, WPCode asks you to confirm the connection. Tick the checkbox and click Connect to WordPress.

💡 Rather not make an account?

Skip ahead to the No Library Account section. You’ll add the same code by hand, and it takes a couple of extra minutes.

You only connect each site once. After that, you can install free library snippets with one click.

Once your site is connected, hover over the card again. This time it shows you two buttons: Use snippet and Preview.

Click Use snippet.

Snippet Library: search results for 'duplicate'; card shows 'Duplicate Post/Page Link' with 'Use snippet' and 'Preview' buttons.
After connecting, the snippet card shows the Use snippet button.

Step 3: Switch the Snippet On

WPCode adds the snippet to your site and opens it in the Edit Snippet screen. The code and settings are already filled in for you, so leave them as they are.

Then, in the Insertion box, leave Auto Insert selected and make sure the Location is set to Admin Only.

This means the code runs in your WordPress dashboard, where the Duplicate link appears, rather than loading on the pages your visitors see.

See the screenshot below to check these settings.

Settings panel for PHP snippet insertion: Auto Insert selected, Location set to Admin Only, with Load as file and Schedule snippet options visible.
The snippet’s Insertion settings: Auto Insert, with the location set to Admin Only.

WPCode saved the snippet when you clicked Use snippet, but it starts switched off.

Look at the top right of the screen, where the toggle next to the Update button says Inactive.

Click the toggle so it says Active, then click Update. That’s it.

Snippet editor UI showing 'Edit Snippet' with a PHP code preview and an Update button highlighted, used to copy/modify a post/page link action snippet.
Switch the snippet to Active, then click Update to save it.

Step 4: Click Duplicate on Any Post or Page

With the snippet active, go to Pages » All Pages, or Posts » All Posts depending on what you want to duplicate.

Hover over the one you want to copy and a row of links appears under the title. Click Duplicate in that row.

For our example, we’re copying our Black Friday Sale page to reuse it for next year’s sale.

WordPress Pages admin list with the item 'Black Friday Sale' selected and a red arrow pointing to it.
The new Duplicate link in the row of actions under a page title.

WPCode creates the copy and opens it in the editor right away.

The title ends in (copy), and the Status in the sidebar says Draft. Take a look at the sidebar in the screenshot below.

Screenshot of a content editor with page title 'Black Friday Sale (copy)' and draft status in the right panel.
The duplicated page opens as a draft, with “(copy)” added to its title.

You might notice the Slug in that sidebar is the same as your original page. Don’t worry, your live page is untouched. The copy is a separate draft.

When you publish it, WordPress adds “-2” to the end of its URL so the two pages don’t clash. We’ll cover how to set your own URL below.

No Library Account? Paste the Snippet Instead (Free)

The library account is free, but you don’t have to make one.

The same code is published on the WPCode Library website, so you can copy it from there and paste it into a blank snippet yourself.

To do this, open the Duplicate Post/Page Link page in the WPCode Library and click the Copy icon.

Screenshot of a page titled 'Duplicate Post/Page Link' with a short description and action icons in the top-right (Add to Site, Add to Library, share/code options).
The Duplicate Post/Page Link snippet on the WPCode Library website, with its Copy button.

Back in WordPress, go to Code Snippets » + Add Snippet.

Hover over Add Your Custom Code (New Snippet) and click + Add Custom Snippet.

WPCode allows you to pick different types of code snippets like CSS, HTML, JavaScript, and more from this screen. To duplicate a page or post, click PHP Snippet.

Code type selection dialog with eight options: HTML, Text, Blocks, CSS, SCSS, JavaScript, PHP, and Universal Snippets.
Choose PHP Snippet from the list of code types.

Give the snippet a name you’ll recognize, like “Duplicate Post/Page Link,” and paste the code into the code box.

Scroll down to the Insertion box and leave Auto Insert selected.

Then, open the Location dropdown and change Run Everywhere to Admin Only, the same setting used by the library version.

Finally, switch the toggle to Active and click Save Snippet.

If you’re new to PHP snippets, our guide to adding PHP to WordPress walks through the editor in more detail.

That’s the whole setup. Your Duplicate link now works exactly like the one in Step 4.

What Gets Copied (and What Doesn’t)

We tested the snippet on a post with a featured image, a category, a tag, a custom field, and an SEO title and description. Here’s what the copy kept.

Item On the copy What that means
Content and blocks Copied Same layout, text, and images in the body
Excerpt Copied Same summary text
Featured image Copied No need to set it again
Categories and tags Copied Same terms as the original
Custom fields Copied Includes anything plugins save as custom fields, like page templates and many page builder layouts
Parent page, order, and password Copied The copy sits in the same place in your page tree
Title Original title + “(copy)” Easy to spot in your list
Status Draft A private, scheduled, or sticky original still copies as a plain draft
Author You Whoever clicked Duplicate
Date Today Not the original’s date
URL slug Same as original until published, then “-2” Set your own before publishing
SEO title and description Depends on your SEO plugin All in One SEO keeps these outside custom fields, so they didn’t carry over in our test
Comments Not copied The copy starts with none

The Author, Date, URL slug, and SEO rows are the ones to check before you publish.

Before You Publish the Copy

Before the copy goes live, fix a few things. Change the title by deleting “(copy),” or write the new title.

Next, set the URL yourself. In the sidebar, click the value next to Slug and type the URL you want, like black-friday-sale-2027. If you skip this, the copy goes live with “-2” on the end of the original URL.

Check your SEO title and description. If your SEO plugin didn’t carry them over, add them again in its settings panel, and update them for the new page while you’re there.

The copy also lists you as the author. If someone else should get the byline, change Author in the sidebar.

Last, keep test copies out of search. If you have to publish a copy you’re only testing, turn on the “no index” option in your SEO plugin’s settings for that page.

Then publish it like any other page.

Bonus: Use Snippet Packs on Your Other Sites

Setting up another site? Open the Snippet Packs tab under Code Snippets » + Add Snippet.

The free Admin Productivity pack installs and switches on this snippet plus three more: a featured image column, a last login column, and a last modified column.

Each site connects to the library on its own, so you’ll connect the new site once too. Log in with the free WPCode account you made in Step 2. The pack then installs all four snippets at once, with nothing to set up one by one.

The Admin Productivity snippet pack listing Duplicate Post/Page Link, Add Featured Image Column, Last Login Column, and Add Last Modified Column
The Admin Productivity snippet pack includes the Duplicate Post/Page Link snippet and three admin columns.

Already built your own snippets on this site? You can export them and import them on the new one.

FAQs: Duplicate Post in WordPress

Does duplicating a post hurt SEO?

Not on its own. Drafts aren’t public, so search engines don’t see them. The risk comes from publishing two pages that say the same thing. Change the content, title, and URL of the copy before it goes live, or keep it as a draft.

First, check that the snippet says Active in Code Snippets. The link also only appears when you hover over a title in the list. And it only shows for content your role can create. On a standard site, that means Editors and Administrators for pages, plus Authors and Contributors for posts.

Does this work for WooCommerce products?

Use WooCommerce’s own link for products instead. Products show two Duplicate links, one from the snippet and one from WooCommerce. To tell them apart, hover over each and check the address at the bottom of your browser. WooCommerce’s contains “duplicate_product,” and it’s built to handle product details like the SKU.

Does it copy page builder layouts?

Usually, yes. Page builders like Elementor save the layout as custom fields, and the snippet copies every custom field. Open the copy in your builder once to check everything came across.

Can I duplicate custom post types?

Yes, if the post type has its own list in your dashboard menu, like Events or Portfolio, and your role can create it. The Duplicate link shows in that list the same way.

Go to Code Snippets, find Duplicate Post/Page Link, and switch it to Inactive. The link disappears right away. Any copies you already made stay where they are, as normal posts and pages.


Start Duplicating Posts and Pages in WordPress

You now have a Duplicate link on every post and page, and you know what to check before a copy goes live.

Try it on the page you rebuild most often. If it’s a sale page, here’s how to add a countdown timer in WordPress to go with it.

Want to add more small fixes like this without touching your theme’s files?
Get WPCode for free →

Want to save your own snippets to the cloud and reuse them on your other sites?
See WPCode Pro →


Additional Resources

A few guides for getting more out of the snippets you add.


Add A Comment


Get WPCode

Popular Resources

Get free tips and resources right in your inbox, along with 500+ others

Follow Us

Get Started Today & Add Your Own Snippets

Future-proof your website with WPCode Snippets and improve the way you manage code across all your websites.