moving to the new style of calling taxonomy

Support General moving to the new style of calling taxonomy

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5813
    cornwallcollegecornwallcollege
    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.

    #5842
    Anh TranAnh 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
    cornwallcollegecornwallcollege
    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 TranAnh 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 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.