Custom Fields
Support General Need help with displaying text field on woocommerce product category page

  • Creator
  • #21921

    Hi there,

    I am using the Metabox builder to create Metaboxes.

    I would like to add a textarea field to the woocommerce product_category taxonomy. The theme that I'm using is Astra.

    I have added this code to my functions.php file:

    //custom Metabox test JP
    add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
    function prefix_register_meta_boxes( $meta_boxes ) {
        $prefix = '';
    $meta_boxes[] = [
        'title'      => esc_html__( 'Product categorie text', 'text-domain' ),
        'id'         => 'product-categorie-text',
        'fields'     => [
                'id'   => $prefix . 'textarea_1jtphdq0vy',
                'type' => 'textarea',
                'name' => esc_html__( 'Textarea Field', 'text-domain' ),
        'taxonomies' => ['product_cat'],
    return $meta_boxes;
    //Function to dispay the field on the product-category page
    add_action( 'woocommerce_after_shop_loop', 'product_category_intro', 13, 3 );
    function product_category_intro() {
        $value = rwmb_meta( 'textarea_1jtphdq0vy' );
        echo $value;

    The metabox is displaying correctly. But the field is not visible on the product category page. What am I doning wring here?

    This is the product category page that I tested:

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #21925
    Long Nguyen


    To get field value from terms, we have to use this format.

    rwmb_meta( $field_id, array( 'object_type' => 'term' ), $term_id )

    Also, this action hook does not accept any arguments so you should remove 3 after 13. The code should be:

    //Function to dispay the field on the product-category page
    add_action( 'woocommerce_after_shop_loop', 'product_category_intro', 13 );
    function product_category_intro() {
        $term_id = get_queried_object_id();
        $value = rwmb_meta( 'textarea_1jtphdq0vy', array( 'object_type' => 'term' ), $term_id );
        echo $value;

    For more information, please follow this documentation


    Thank you Long, that did the trick.

    Is there a way to change the order of the custom metabox? I would like the new metabox to be shown as 1st in the list.

    Kind regards, Jan

    Long Nguyen


    This CSS code (admin area) would help you to show the term meta box first, above the default form.

    .taxonomy-product_cat form#edittag {
        display: flex;
        flex-wrap: wrap;
    .taxonomy-product_cat form#edittag .rwmb-meta-box {
        order: -1

    Apply the admin CSS code with this plugin

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.