How to set meta value from a taxonomy field?

Support General How to set meta value from a taxonomy field?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38191
    closemarketingclosemarketing
    Participant

    I have a meta like this:

    array(
    				'name'        => __( 'Related proceedings', 'textdomain' ),
    				'placeholder' => __( 'Select the related proceedings', 'textdomain' ),
    				'id'          => "{$prefix}related_prod",
    				'type'        => 'taxonomy',
    				'taxonomy'    => 'category',
    				'field_type'  => 'select_advanced',
    				'add_new'     => true,
    			),

    How could set up a value to this meta field?
    I've tried with rwmb_set_value but I couldn't manage to work.

    #38195
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please follow the sample code in the documentation to know how to set a taxonomy field value.
    https://docs.metabox.io/functions/rwmb-set-meta/

    add_action( 'init', function() {
        rwmb_set_meta( 123, 'related_prod', 456 );
    }, 99 );

    where 123 is the post ID
    456 is the term ID
    and check the correct field ID related_prod (with prefix).

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