post_custom_meta_box

The timeline below displays how wordpress function post_custom_meta_box has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Displays custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param WP_Post $post Current post object.
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
	<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p>
	<?php 
    printf(
        /* translators: %s: Documentation URL. */
        __('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'),
        __('https://wordpress.org/documentation/article/assign-custom-fields/')
    );
    ?>
</p>
	<?php 
}

WordPress Version: 6.1

/**
 * Displays custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param WP_Post $post Current post object.
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
	<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p>
	<?php 
    printf(
        /* translators: %s: Documentation URL. */
        __('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'),
        __('https://wordpress.org/support/article/custom-fields/')
    );
    ?>
</p>
	<?php 
}

WordPress Version: 5.6

/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param WP_Post $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
	<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p>
	<?php 
    printf(
        /* translators: %s: Documentation URL. */
        __('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'),
        __('https://wordpress.org/support/article/custom-fields/')
    );
    ?>
</p>
	<?php 
}

WordPress Version: 5.3

/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
	<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p>
	<?php 
    printf(
        /* translators: %s: Documentation URL. */
        __('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'),
        __('https://wordpress.org/support/article/custom-fields/')
    );
    ?>
</p>
	<?php 
}

WordPress Version: 5.1

/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
	<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p>
	<?php 
    printf(
        /* translators: %s: Codex URL */
        __('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'),
        __('https://codex.wordpress.org/Using_Custom_Fields')
    );
    ?>
</p>
	<?php 
}

WordPress Version: 4.5

/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p><?php 
    printf(
        /* translators: %s: Codex URL */
        __('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'),
        __('https://codex.wordpress.org/Using_Custom_Fields')
    );
    ?></p>
<?php 
}

WordPress Version: 4.2

/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p><?php 
    _e('Custom fields can be used to add extra metadata to a post that you can <a href="https://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.');
    ?></p>
<?php 
}

WordPress Version: 3.7

/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p><?php 
    _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.');
    ?></p>
<?php 
}