Show custom fields on submit page

Hi, I created a metabox with custom fields in it using this code:

add_filter(
	'hivepress/v1/meta_boxes',
	function( $meta_boxes ) {
		$meta_boxes['custom_meta_box'] = [
			'title'  => 'Custom Meta Box',
			'screen' => 'listing',

			'fields' => [
				'custom_option' => [
					'label'  => 'Custom Option',
					'type'   => 'checkbox',
					'_order' => 123,
				],
			],
		];

		return $meta_boxes;
	}
);

Now I’m wondering how to make the same metabox or fields in the metabox to appear on the submit page. Any guidance? Thank you

Hi,

We recommend using this hook hivepress/v1/models/listing/attributes Filter: hivepress/v1/models/{model_name}/attributes | HivePress Hook Reference, with this hook, the data will be added to the metabox and submit page, and will be stored correctly. Also, you can check these samples Search · user:hivepress hivepress/v1/models/listing/attributes · GitHub

​I hope this is helpful to you.

Thank you. To display the field in both the metabox and submit page tried this:

add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes) {
		$attributes['custom_field'] = [
'course' => [
                    'label' => 'Course',
                    'type' => 'repeater',
            'fields' => [
            'course_name' => [
           'label' => 'Course Name',
           'type' => 'text',
        ],
                      
            'duration' => [
           'label' => 'Duration',
           'type' => 'text',
        ],
],
],
],
return $attributes;
}
);

But I’m get this error: Warning: Undefined array key “type” in … plugins\hivepress\includes\models\class-model.php on line 145

How can I make it work?

Hi,

To add PHP snippets, I recommend using the Code Snippets plugin, please check this doc How to add custom code snippets - HivePress Help Center. You’re using the API incorrectly, so I recommend reviewing this documentation Filter: hivepress/v1/models/{model_name}/attributes | HivePress Hook Reference
Also, If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.