Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicki Hastings nickihastings

View GitHub Profile
@nickihastings
nickihastings / aux-functions.php
Last active Feb 18, 2020 — forked from fredrikwoll/aux-functions.php
Programmatically duplicating a WordPress post
View aux-functions.php
<?php
/**
* Duplicates a post & its meta and it returns the new duplicated Post ID
* @param [int] $post_id The Post you want to clone
* @return [int] The duplicated Post ID
*/
function duplicate($post_id) {
$title = get_the_title($post_id);
$oldpost = get_post($post_id);
You can’t perform that action at this time.