• 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

    (@philsola)

    Hi, is there anyone that can help with this still?

    It’s such a needed feature of this plugin.

    Thanks

    Plugin Support Mushrit Shabnam

    (@611shabnam)

    Hi @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

    (@philsola)

    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.