Title: Rewrite &amp; Republish Programatically
Last modified: August 24, 2023

---

# Rewrite & Republish Programatically

 *  [Philip Sola](https://wordpress.org/support/users/philsola/)
 * (@philsola)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/rewrite-republish-programatically/)
 * Hi,
 * I have been trying to find a way to create a draft post using the rewrite and
   republish feature programmatically but I am struggling to find one.
 * Looking at the developer docs on your site, there are certain functions available
   for developers, such as duplicate_post_create_duplicate() but I can’t see anything
   for duplicate_post_for_rewrite_and_republish(). Is this possible or can someone
   help me to get this working?
 * It is almost essential functionality that I would need for an upcoming build 
   and can’t see any other way to do this.
 * Any help would be greatly appreciated, and thank you in advance.
 * Phil

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Philip Sola](https://wordpress.org/support/users/philsola/)
 * (@philsola)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/rewrite-republish-programatically/#post-17234633)
 * Hi, is there anyone that can help with this still?
 * It’s such a needed feature of this plugin.
 * Thanks
 *  [Mushrit Shabnam](https://wordpress.org/support/users/611shabnam/)
 * (@611shabnam)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/rewrite-republish-programatically/#post-17742892)
 * Hi [@philsola](https://wordpress.org/support/users/philsola/)
 * To create a draft post using the rewrite and republish feature programmatically,
   you can use something like this:
 * use Yoast\WP\Duplicate_Post\Post_Duplicator;
 * $post_duplicator = new Post_Duplicator();
 * $new_post_id = $post_duplicator->create_duplicate_for_rewrite_and_republish( 
   $post );
 *  Thread Starter [Philip Sola](https://wordpress.org/support/users/philsola/)
 * (@philsola)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/rewrite-republish-programatically/#post-17742974)
 * Amazing, thank you so much for your help Mushrit!
 * I’ll give this a go!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Rewrite & Republish Programatically’ is closed to new replies.

 * ![](https://ps.w.org/duplicate-post/assets/icon-256x256.png?rev=2336666)
 * [Yoast Duplicate Post](https://wordpress.org/plugins/duplicate-post/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/duplicate-post/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/duplicate-post/)
 * [Active Topics](https://wordpress.org/support/plugin/duplicate-post/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/duplicate-post/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/duplicate-post/reviews/)

## Tags

 * [feature](https://wordpress.org/support/topic-tag/feature/)

 * 3 replies
 * 2 participants
 * Last reply from: [Philip Sola](https://wordpress.org/support/users/philsola/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/rewrite-republish-programatically/#post-17742974)
 * Status: not resolved