llms_update_util_post_duplicator( int $id )

Duplicate a WP Post & all relate metadata.


Parameters Parameters

$id

(int) (Required) WP Post ID.


Top ↑

Return Return

(int) WP Post ID of the new duplicate.


Top ↑

Source Source

File: includes/functions/llms.functions.updates.php

function llms_update_util_post_duplicator( $id ) {

	$copy = (array) get_post( $id );
	unset( $copy['ID'] );
	$new_id = wp_insert_post( $copy );
	foreach ( get_post_custom( $id ) as $key => $values ) {
		foreach ( $values as $value ) {
			add_post_meta( $new_id, $key, maybe_unserialize( $value ) );
		}
	}

	return $new_id;

}


Top ↑

Changelog Changelog

Changelog
Version Description
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.