PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 26, 2022

[FIXED] how to add custom meta box for woocommerce review?

 August 26, 2022     php, woocommerce, wordpress     No comments   

Issue

I want to show some information in woocommerce review edit section and I don't know how to put them in woocommerce review I tested this code in bottom but it doesn't work

function kral_product_review_metabox() {
    add_meta_box(
        'kral_product_review',
        'اطلاعات دیدگاه',
        'kral_product_review_fields_metabox',
        'product-reviews',
        'side',
        'high'
    );
}
add_action('add_meta_boxes', 'kral_product_review_metabox');

function kral_product_review_fields_metabox($post) {

    wp_nonce_field(basename(FILE), 'kral_product_review_nonce');

?>
    <p>
        <label for="kral_product_name">label</label>
        <br />
        <input class="widefat" type="text" name="kral_product_name" id="kral_product_name" value="salaaaaaaaaaaaaam" />
    </p>
<?php
}

Solution

You are using the wrong post type value as screen value and the wrong context value.

The correct screen name will be comment not product-reviews

WordPress Documentation says that you can use side as context value when adding meta boxes on the comments page but I am not sure why it doesn't work with the side value.

Correct add_meta_box code will look like this:

add_meta_box(
    'kral_product_review',
    'اطلاعات دیدگاه',
    'kral_product_review_fields_metabox',
    'comment',
    'normal',
);


Answered By - Vijay Hardaha
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing