Skip Navigation

[Résolu] Using generic date field to set post date

This support ticket is created Il y a 5 années et 4 mois. There's a good chance that you are reading advice that it now obsolete.
Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 0 réponses, has 1 voix.

Last updated by davidS-53 Il y a 5 années et 4 mois.

Assisted by: Shane.

Auteur
Publications
#1158111

I have the following fields to create a child post with content based on some generic fields.

		$notes = $_POST['notes'];
		$date_checked = $_POST['date-checked'];
		$checked_by = $_POST['checked-by'];
		$photo = $_POST['photo'];

		$title = "Log Item " . $date_checked . $checked_by;
                $slug = sanitize_title($title);

		$log_item = array(
			'post_title' => $title,
			'post_name' => $slug,
			'post_content' => $content,
			'post_status' => 'publish',
			'post_type' => 'log-item',
			'meta_input' => array(
				'wpcf-notes' => $notes,
				'wpcf-date-checked' => $date_checked,
				'wpcf-checked-by' => $checked_by,
				'wpcf-belongs-to-id' => $post_id,
				'wpcf-photos' => $photo,
			),
		);

		$log_item_id = wp_insert_post( $log_item , $wp_error );

I'm trying to set the post date using the value of

$date_checked

, but this seems to send as an array- not sure why that would be since it's a single date value? For example, currently above code produces a log item titled "Log Item Array User"

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.