• Resolved dwcouch

    (@dwcouch)


    I’m not sure when exactly it happened. Client reported the missing field ~ January 10. But it may have been missing before that. I presume it was an upgrade of WordPress or MetaBox that killed it.

    After reviewing the implementation I’m not certain where the hang up is.

    The primary differencce I find to the documentation is the use of the add_filter as follows:

    add_filter( 'rwmb_meta_boxes', 'YOURPREFIX_register_meta_boxes' );
    function YOURPREFIX_register_meta_boxes( $meta_boxes ) {

    vs mine:
    add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {

    It seems all other definitions of metabox for other taxonomies and post types are working EXCEPT the advanced image upload.

    No errors. the field is just not rendering.
    In the admin list view of the custom taxonomies, project types show a featured image specified that can no longer be viewed, edited, or deleted when editing the project type.

Viewing 9 replies - 1 through 9 (of 9 total)
  • I just ran into the same issue on a site I took over using WP 4.7.2 and Meta Box 4.10.3.

    I tried a few recent earlier releases then jumped back to 4.8.7, which is displaying the fields in the admin again.

    Using the code below:

    add_filter( 'rwmb_meta_boxes', 'images' );
    function images( $meta_boxes ) {
        $prefix = 'pfim_';
        $post_types = get_post_types();
    
        $meta_boxes[] = array(
            'title'  => __( 'Images', 'pfim' ),
            'post_types' => $post_types,
            'fields' => array(
                // PLUPLOAD IMAGE UPLOAD (WP 3.3+)
                array(
                    'name'             => __( 'Images for pages / posts', 'pfim' ),
                    'id'               => "{$prefix}pluploader",
                    'type'             => 'image_advanced',
                    'max_file_uploads' => 10,
                )
            )
        );
        return $meta_boxes;
    }

    As with @dwcouch all other meta boxes are working on the same custom post types where advanced images are not.

    Plugin Author Anh Tran

    (@rilwis)

    Hi, I’ve tested again the field and everything seems to work fine to me. I tried @excentricjester’s code and it works (here is the screenshot: https://prntscr.com/e9di80).

    @dwcouch: Your code works well. It’s just the PHP 5.3 syntax and should work without problem.

    I think the bug might relate to something else. Can you provide more info such as which plugins are you using, PHP version and full code to register meta boxes?

    Hi @rilwis,

    I found what the problem was for me.

    The line $post_types = get_post_types(); was working on pages, but not my custom post types because the default is set to 'post_types' => array( 'post', 'page' )

    I updated that line to include my custom post types and it is working everywhere now with version 4.10.3 $post_types = array( 'post', 'page', 'press', 'residential', 'commercial' );

    @dwcouch I suspect you have the same issue, so you might want to check the code inside your function.

    • This reply was modified 7 years, 9 months ago by excentricjester. Reason: Editing code
    Plugin Author Anh Tran

    (@rilwis)

    Nice. That’s why I always recommend manually set the list of post types in the post_types parameter of the meta boxes.

    Thread Starter dwcouch

    (@dwcouch)

    @rilwis,
    I don’t believe this is the case. I’m working on a custom tax for a custom post type. Even so I updated the below code with the lines beginning with /**/. No change.

    
    add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
    	$prefix       = 'ptype_';
    	/**/$post_types = get_post_types();
    
    	$meta_boxes[] = array(
    		'id'         => 'ptype_img_box',
    		'title'      => 'Project Gallery Image',
    		'taxonomies' => array( 'sr_project_types' ),
    		// list of taxonomies. Default is array('category', 'post_tag'). Optional
    		/**/'post_types' => array( 'sr_projects' ),
    		'fields'     => array(
    			//Image
    			array(
    				'name' => __( '	Image will be used for both sizes displayed on the Project Gallery Page in a running bond pattern: <br>  							
    									■ 450 x 300<br>
    									■ 290 x 393<br>', 'rwmb' ),
    				'id'   => "{$prefix}feat_img",
    				'type' => 'image_advanced',
    				'max_file_uploads' => 1
    			)
    		)
    	);
    
    	return $meta_boxes;
    } );
    

    Also I’m seeing the following error:

    
    PHP Fatal error: Call to undefined method RW_Meta_Box::get_class_name() in [***]/wp-content/plugins/mb-term-meta/inc/term-meta-box.php on line 107, referer: [***]/wp-admin/edit-tags.php?taxonomy=sr_project_types&post_type=sr_projects
    
    Thread Starter dwcouch

    (@dwcouch)

    I got to thinking about that undefined method… And recalled the last time this had stopped working – when you updated my site to use the plugin vs the legacy theme integrated version. I had reported the issue with a tax on the metabox thread then too ??

    TLDR;
    I fixed it. The Meta Box extension, MB Term Meta had been updated in January. I installed the update.

    How do you recommend keeping up with Updates to this extension – as I was not notified via the plugin admin of my site?

    Plugin Contributor MetaBox

    (@metabox)

    Hi @dwcouch,

    Are you registering meta boxes for terms instead of posts? If so, the code should be like this (the post_types parameters is removed completely):

    add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
    	$prefix = 'ptype_';
    
    	$meta_boxes[] = array(
    		'id'         => 'ptype_img_box',
    		'title'      => 'Project Gallery Image',
    		'taxonomies' => array( 'sr_project_types' ),
    		'fields'     => array(
    			array(
    				'name'             => __( '	Image will be used for both sizes displayed on the Project Gallery Page in a running bond pattern: <br>  							
    									■ 450 x 300<br>
    									■ 290 x 393<br>', 'rwmb' ),
    				'id'               => "{$prefix}feat_img",
    				'type'             => 'image_advanced',
    				'max_file_uploads' => 1,
    			),
    		),
    	);
    
    	return $meta_boxes;
    } );

    Regarding the Updater extension, you need to register an account on https://metabox.io and then get the API key from the website. Then go to Settings > Meta Box Updater and enter that API key to get the updates.

    For more info, please read this guide:

    https://metabox.io/docs/meta-box-updater/

    Plugin Author Anh Tran

    (@rilwis)

    The last reply was me ??

    Thread Starter dwcouch

    (@dwcouch)

    Oh! No-no-no – My original code did NOT have the post_types parameters. I just thought I’d give it a shot to see if I was missing something. Once I realized the extension was out of date that fixed the issue. Sorry if I confused the issue.

    I’ll get the API and activate the updater.

    Thanks again Anh Tran!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘image_advanced field no longer on custom tax edit screen’ is closed to new replies.