Top Questions

  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Feb 20, 2018

    The hook allows meta box registration for any post type. Passes two parameters: $post_type and $post. Note: You can also use add_meta_boxes_{post_type} for best practice, so your hook will only run when editing a specific post type. This will only receive 1 parameter - $post.

    Add this to functions.php
    add_action( 'add_meta_boxes', 'gp_add_meta_boxes' );
    function gp_add_meta_boxes() {
        add_meta_box( 'gp_product', 'Products Options', 'gp_products_callback', 'review', 'normal', 'high' );
    function gp_products_callback( $post ) {
        $fname = get_post_meta( $post->ID, 'fname', true );
    // reset choices
    	$field['choices'] = array();
    	$users = get_users();
    	<select name="cust_user"></select>
    	foreach ($users as $user) {
    		$field[ $user->ID ] = $user->display_name;
        <p>First Name: <input type="text" name="fname" value="<?php echo $fname; ?>"></p>

Add Your Answer

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.