Skip to content

Instantly share code, notes, and snippets.

View nickihastings's full-sized avatar
🏠
Working from home

Nicki Hastings nickihastings

🏠
Working from home
View GitHub Profile
@nickihastings
nickihastings / aux-functions.php
Last active February 18, 2020 11:05 — forked from fredrikwoll/aux-functions.php
Programmatically duplicating a WordPress post
<?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);