Support

Account

Home Forums Feature Requests Reorder Post Title/Content

Solved

Reorder Post Title/Content

  • Post Title and Post Content can be manually reordered by inserting them later into the $fields[] array at specific indices.

    The array_insert() function is required.

    In \api\api-template.php:

    function acf_form($args = array())
    {
    	[...]
    	// defaults
    	$args = wp_parse_args($args, array(
    		[...]
    		'post_title_position' => 0,
    		'post_content_position' => 1,
    		[...]
    	));
    	[...]
    }

    Below that:

    	// post title
    	if ($args['post_title'])
    	{
    		// rename $fields[] to $post_title_field[]
    		$post_title_field[] = acf_get_valid_field(array(
    			[...]
    			'position' => $args['post_title_position']
    		));
    	}
    
    	// post_content
    
    	if ($args['post_content'])
    	{
    		// rename $fields[] to $post_content_field[]
    		$post_content_field[] = acf_get_valid_field(array(
    			[...]
    			'position' => $args['post_content_position']
    		));
    	}

    And below that:

    	// load fields based on field groups
    	if (!empty($field_groups))
    	{
    		[...]
    	}
    
    	array_insert($fields, $post_title_field[0],   $args['post_title_position']);
    	array_insert($fields, $post_content_field[0], $args['post_content_position']);
    
    	// updated message

    You can then use post_title_position and post_content_position in acf_form().

    <?php acf_form(array(
    	[...]
    	'post_title_position'	=> 2,
    	'post_content_position'	=> 6,
    	[...]
    )); ?>

    Obviously, this quick hack is prone to user error and requires manually updating acf_form() whenever the form is changed. Being able to manage Post Title and Post Content in the ACF admin UI would be more convenient.

  • Hi @fireundubh ,
    Thanks for the feedback.

    I will let the Developer know of this recommendation for consideration.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.