Step 1: Create a Custom Field using “Add New Custom Field” in Single Product Page named as “AuthorName” and give its value. (Screenshot Attached.)
Step 2: Add the following code in fucntion.php File
// Display custom field on the single product page
function display_custom_product_field() {
global $post;
$custom_field_value = get_post_meta( $post->ID, 'AuthorName', true );
if ( ! empty( $custom_field_value ) ) {
echo '<div class="custom-product-field" style="margin-top: -15px;"><strong>Author: </strong>' . esc_html( $custom_field_value ) . '</div>';
}
}
add_action( 'woocommerce_single_product_summary', 'display_custom_product_field', 5 );
——-
Output Image attached.
——-
You can close this Ticket for now.
Attachments:
You must be
logged in to view attached files.