I'm a beginner wordpress plugin developer. Our plugin needs to create some specific pages in wordpress. My plugin can create the pages this way in the activation:
$page_id = wp_insert_post(
array(
'comment_status' => 'close',
'ping_status' => 'close',
'post_author' => 1,
'post_title' => ucwords('service network login'),
'post_name' => strtolower(str_replace(' ', '-', trim('service-network-login'))),
'post_status' => 'publish',
'post_content' => '',
'post_type' => 'page',
)
);
It's ok, I can find my page. After that I would like to add some php codes to this new page.
I know here can call a php function which generates some html content fo example this way:
'post_content' => my_php_function()
But in this case if I change the content of the my_php_function(), then it doesn't affect page content if I refersh the page in browser.
I tried add template file to the page:
update_post_meta( $page_id, '_wp_page_template', 'template.php' );
But it doesn't work.
How can I create pages from plugin with dinamic content?
Thank you!