post_custom_meta_box() WordPress Function
The post_custom_meta_box() function is a powerful tool that allows you to add custom fields to your posts and pages. Using this function, you can add text, images, and other data to your posts and pages, making them more engaging and informative. Additionally, you can use this function to create custom fields for your comments section, allowing you to gather more information from your readers.
post_custom_meta_box( WP_Post $post ) #
Displays custom fields form fields.
Parameters
- $post
(WP_Post)(Required)Current post object.
Source
File: wp-admin/includes/meta-boxes.php
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 }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |