Skip to content

Instantly share code, notes, and snippets.

@jan-koch
Created November 15, 2018 12:05
Show Gist options
  • Save jan-koch/7fbec8d1a0b89fd6761343a9245e77e0 to your computer and use it in GitHub Desktop.
Save jan-koch/7fbec8d1a0b89fd6761343a9245e77e0 to your computer and use it in GitHub Desktop.
Example of adding a custom textarea to the "General" tab of a WooCommerce product.
<?php
function prefix_add_textarea() {
$args = array(
'label' => '', // Text in the label in the editor view
'placeholder' => '', // Give advice or examples as placeholder
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, will be loaded as meta_value for the meta_key with the given id
'id' => '', // required, serves as meta_key for this field
'name' => '', // name will be set automatically from the id if left empty
'rows' => '',
'cols' => '',
'desc_tip' => '',
'custom_attributes' => '', // array of attributes you can pass
'description' => ''
);
woocommerce_wp_textarea_input( $args );
}
add_action( 'woocommerce_product_options_pricing', 'prefix_add_textarea' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment