delete_row()

Overview

This function will delete a row of data from an existing repeater field or flexible content field value.

Change Log

  • Added in version 5.3.2

Parameters

delete_row( $selector, $row, $post_id )
  • $selector: (required) The parent field name or key
  • $row: (required) The row number to delete
  • $post_id: (optional) The post ID of which the value is saved to. Defaults to current post

Return

This function will return true upon success or false upon failure.

Notes

  • Row numbers start from 1 (not 0). For example, the first row of values is considered $i = 1
  • It is possible to change the row index starting point so that row numbers start from 0 using the row_index_offset setting.

Examples

Basic

This example demonstrates how to delete a row of data from an existing repeater field called ‘images’.

<?php 

$row = array(
	'image'	=> 123,
	'alt'	=> 'Another great sunset',
	'link'	=> 'http://website.com'
);

delete_row('images', 1);
	
?>

Related