• Hello. Sorry for the idiot question, but I really don’t know what to do here. Inexperienced with php in general.

    I’m wanting a metabox that will allow the user to create a ‘link’ to an existing post. So I figured I wanted the ‘post’ field type. Creating the metabox and getting it to show the posts for selection is working OK, but I’m having trouble getting the result to show on the template.

    Here is what I have in functions at the moment:

    add_filter( 'rwmb_meta_boxes', 'lio_register_meta_boxes' );
    function lio_register_meta_boxes( $meta_boxes )
    {
    	$prefix = 'lio_';
    	$meta_boxes[] = array(
    		'id'         => 'linked_listing',
    		'title'      => esc_html__( 'Linked Listing', 'lio' ),
    		'post_types' => array( 'officialreview' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    			array(
    				'name'        => esc_html__( 'Restaurants', 'lio' ),
    				'id'          => "{$prefix}pages",
    				'type'        => 'post',
    				'post_type'   => 'restaurant',
    				'field_type'  => 'select_advanced',
    				'placeholder' => esc_html__( 'Select a listing', 'lio' ),
    				'query_args'  => array(
    					'post_status'    => 'publish',
    					'posts_per_page' => - 1,
    				),
    			),
    		)
    	);
    	return $meta_boxes;
    }
    rwmb_meta( $field_id, $args = array(), $post_id = null );

    And here is what I’ve dropped into the template:

    <?php echo rwmb_meta( 'lio_linked_listing', $args, $post_id ); ?>

    But I’m obviously making a stupid mistake because there’s just nothing showing at all.

    Sorry again for what I’m sure is a really simple question!

    Thank you.

    https://www.ads-software.com/plugins/meta-box/

  • The topic ‘Help for complete newbie’ is closed to new replies.