Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I want to create a page in Wordpress with code and do not want to set a custom field value while creating the page.

What I have tried:

Tried creating the page using this code but not able to set a custom field value.
// Create post object
$my_post = array(
	'post_type'     => 'page',
	'post_title'    => 'My post',
	'post_content'  => 'This is my post.',
	'post_status'   => 'publish',
	'post_author'   => 1
  );
 
  // Insert the post into the database
 wp_insert_post( $my_post );
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900