The Duplicate Post Form widget enables users to duplicate existing posts from the frontend of a WordPress website, without needing to interact with the WordPress dashboard. The form also allows the user to edit the new copy of the post before publishing.
Important: By default a user needs to be logged in and carry the “administrator” role to access the form. This can be changed, however, in the Permissions settings of this widget.
The Duplicate Post Form functions almost exactly like the Post Edit Form widget. The only difference is that instead of editing the existing post, this widget creates a new post and copies the data into the form. This means the fields are prefilled with the data from the existing post. The rest of the functionality is identical to the Post Edit Form widget.
We can add the widget to a Single Post Template in Elementor to have it appear automatically on all posts, just like the Post Edit form. You can also use the form to duplicate a specific post. This is explained more in the Post section below.
Adding the Widget
If you don’t already have a template for your posts, you need to create one. To create a new template click “Add New” under Templates in the WordPress dashboard. Choose Single Post to create a template for your posts.
You can choose to insert an existing template to edit or start from scratch. You can learn more about templates in Elementor’s official tutorial here.
Navigate to the template’s edit page by clicking Edit with Elementor, and drag in the Duplicate Post Widget. This can be found in the Frontend Forms section or by searching for the “Duplicate Post” widget.
The structure of the form itself is highly customizable. All the options from the Edit Post Form are available. We will give an overview about each field here, and full in depth articles are on the way.
By default, the form will have the Title, Slug, Content, Featured Image, Excerpt, Categories, and Tags fields activated. These can be customized to whatever fits your needs.
Adding and Removing Fields
To add more fields simply click the Add Item button. The form on your page will change to reflect these new fields. Fields can also be deleted by clicking the X.
You can add ACF fields by clicking Add Item and changing the field type to ACF Fields or ACF Fields Groups and then selecting the desired fields or groups.
The Form Title is the title for the entire form. By default it will be called “Duplicate Post”, but it can be left blank if you wish.
At the very bottom we can edit the text displayed on the Submit button.
Basic Field Attributes
The Field Type defines the type of field being edited. Changing this will affect the other available options.
All the field types have options which can be changed to customize both the content and the style of the field.
- Label – This is shown above the field’s text box. This can be toggled to be displayed or hidden according to your needs.
- Placeholder – This defines placeholder text to be shown within the text box. By default it is left blank to show nothing.
- Default Value – This will populate a field if no value has been given yet. You can also use shortcodes from other text fields. For example: [$acf:field_name].
- Instruction – This is shown in smaller text under the Label.
- Required – Indicates if the field can be left blank.
- Disabled – This will prevent users from editing the field and will not send the data.
Field Specific Options
As mentioned above, there are many options which are unique to a specific field type. We will cover some of the options for the default fields. There will be more articles going in depth about each field’s options.
The Title Field is a simple text box. We have the standard Label, Instruction etc. Additionally, there is an option for adding Placeholder text, indicating what type of content is expected from the user. Note this will not change the slug.
The Slug Field is also a text box, where the user can edit the URL slug of the new post. Since the field will be prepopulated with the slug of the original post, if the user does not change it the content will be the same as the slug for the original post. Since multiple posts can not have the same slug, “_copy2” will automatically be added to the end of the URL for the new post.
The Content Field is also a text box. You can customize the text box type, it can be a Text Area or a Text Editor.
This allows your users to edit the featured image for the post. In addition to the basic attributes, you can add a default image for the form.
This allows the users to select the category for the post, using the standard “Category” field of WordPress posts.
We can restrict the user to a single choice or allow multiple selections.
The single choice options are radio buttons or select (dropdown), and the multi-choice options include checkboxes or multi-select.
Additionally, we have the option to allow the user to add more categories right from the form, with the Add Term setting.
Here we have several options for additional actions to take place outside the form itself such as sending an email when the form is submitted.
You can customize where the page redirects to after submitting. By default it will stay on the current page. If you want the user to see the new post you can choose Post URL.
Additionally, you can redirect them to a different page of your choosing, or even dynamically redirect to the page which linked to this one.
By default, there is a success message which is displayed after the form is submitted. This can be customized, and can even include dynamic data. For example, you can use the [post:title] shortcode to display the current post’s title as part of the message.
If you would prefer no success message it can be easily hidden by toggling off the Show Success Message button.
Here you can configure which post to duplicate. The default is the current post, ie the current page. This is best used when the widget is in a template as explained above.
You can also use a URL query or set a specific post to be duplicated every time. In this case the form could be hosted on a static page instead of a template.
This is where we limit which kinds of users can access the form. It is very important to configure this correctly, as otherwise your users might not be able to see the form at all!
No Permissions Message
There is a message displayed to those who try to access the form without sufficient permissions. This is configured under the No Permissions Message option.
The default is a simple text based message. You also have the option to use custom content with the full Text Editor, complete with formatting, images, and even shortcodes. If you prefer no message then simply choose None.
By default, only administrators can see the form. If you want to allow other users to access it, you need to add them. There are several ways to do that.
First you can specify whether or not users need to be logged in to view the form, under the Who Can See This… option.
You can allow certain Roles to access the form under the Select By Role option. This allows you to add all Editors, for example.
You can also add specific users under the Select By User option. The users selected here will always be able to see the form.
If you would like the author of the post to be able to edit his/her post, you will need to add that under the Dynamic Permissions option.
Saving the Template
When you finish designing the form, you will need to save the template. You can limit the template to specific pages or post types and that will ensure the Duplicate button is only shown on those types of posts. If you want the button to appear on all pages don’t add any conditions to the template.
Now you have a duplicate button for all your posts!