1. Home
  2. Developer’s guide
  3. Functions & Template tags
  4. duplicate_post_get_original

duplicate_post_get_original

Description

Returns the original post, either as a post object, an associative array or a numeric array (depending on the $output parameter).

It relies on the _dp_original custom field, which is set to the original ID every time the plugin creates a copy.

It is modeled after get_post().

Usage

<?php $original_post = duplicate_post_get_original( $post, $output ); ?>

Parameters

  • $post
    • (int|WP_Post|null) (Optional) Post ID or post object. Defaults to global $post.
      • Default value: null
  • $output
    • (string) (Optional) The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively.
      • Default value: OBJECT

Return values

  • the original post, if successful
  • null if the submitted post doesn’t exist or if it hasn’t any _dp_original custom field, or if it’s empty