Custom Fields
Re-Envisioned
Support General moving to the new style of calling taxonomy

This topic contains 3 replies, has 2 voices, and was last updated by  Anh Tran 1 year, 11 months ago.

  • Creator
    Topic
  • #5813

    cornwallcollege
    Participant

    Hi We’ve been using the plugin for a few years now so a lot of our code uses the old way of handling Taxonomy
    $tax_list = rwmb_meta( '', 'type=taxonomy&taxonomy=stuff' );
    Been trying to convert the code to see if it fixes a ‘property of non-object’ problem that has appeared since upgrading to the latest version of metabox.
    We are finding that if we use the new simple format:
    $tax_list = rwmb_meta( 'stuff' );
    nothing is being returned if we try to use it or even print out the array.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #5842

    Anh Tran
    Keymaster

    Hi Matt,

    The problem is previously you might use this code to register meta boxes:

    add_action( 'admin_init', 'prefix_register' );
    function prefix_register() {
        // Some code here
    }

    Or something like this:

    if ( is_admin() ) {
        add_action( 'rwmb_meta_boxes', 'prefix_register' );
        function prefix_register( $meta_boxes ) {
            // Some code here
        }
    }

    It’s required to switch to simpler syntax like this:

    add_action( 'rwmb_meta_boxes', 'prefix_register' );
    function prefix_register( $meta_boxes ) {
        // Some code here
    }

    in order to make the rwmb_meta work.

    #5846

    cornwallcollege
    Participant

    Thanks for your reply.

    I changed:

    add_action( 'init', 'course_register_meta_boxes' );
    function course_register_meta_boxes( $meta_boxes ){
    add_filter( 'rwmb_meta_boxes', 'course_register_meta_boxes' );

    to:

    add_action( 'rwmb_meta_boxes', 'course_register_meta_boxes' );
    function course_register_meta_boxes( $meta_boxes ){
    add_filter( 'rwmb_meta_boxes', 'course_register_meta_boxes' );

    and converted the calls to the new style, but still not outputting anything.
    Anything else I need to check?

    #5852

    Anh Tran
    Keymaster

    Looks like your code is duplicated somehow, please try:

    add_action( 'rwmb_meta_boxes', 'course_register_meta_boxes' );
    function course_register_meta_boxes( $meta_boxes ){
        $meta_boxes[] = ...
        return $meta_boxes;
    }

    Also, please check if that code is loaded before init hook.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.