Changing attributes order in add listing and listing edit page

Hello,
Is it possible to change default attributes order in submit listing form? I would need to change description / youtube / spotify order.

Please try this PHP snippet to start. In this way, it is possible to change the order for other fields in the listing submit form

add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
		$form['fields']['description']['_order'] = 1;

		return $form;
	},
	1000
);

Hmm, i tried it, but it looks like that this snippet moves selected field to top and doesn’t look at the number that was inserted. For example I have 4 fields that have 1,2,3,4 order numbers and I insert 5 into description field, but the description field is still at the top, but it should be below the 4th attribute.

$form[‘fields’][‘description’][’_order’] = 5;

Please make sure that you have set the correct field names for other fields to change their order. For example, it will be $form['fields']['title']['_order'] for field Title. If you’re familiar with PHP basics please try to output the fields this way:

add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
        var_dump($form['fields']);
		die();
		return $form;
	},
	1000
);

This will output all the fields keys/field names on the front-end, so you’ll be able to use them with a sample snippet above to re-order any fields

Also, you can share your code snippet here if the issue persists

It works great in listing submit form. but how to do the same for listing edit page?

add_filter(
'hivepress/v1/forms/listing_submit',
function( $form ) {
$form['fields']['title']['_order'] = 2;
$form['fields']['images']['_order'] = 3;
$form['fields']['description']['_order'] = 4; 

return $form;
},
1000
);

Please change listing_submit to listing_update

Thanks, I got it. And how about front end. Would you please write a snippet code sample to reorder images 1, title 2, description 3

add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
        var_dump($form['fields']);
		die();
		return $form;
	},
	1000
);

Please try the same snippet but for the listing_update form:

add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
$form['fields']['title']['_order'] = 2;
$form['fields']['images']['_order'] = 3;
$form['fields']['description']['_order'] = 4; 

return $form;
},
1000
);

Change 2, 3, 4 numbers to adjust the order. This will also affect the listing_submit form if there’s no specific snippet for it since this form inherits the listing_update one.

5 Likes

Thanks it works great!

1 Like

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