我使用此功能创建WordPress页面:
function adv_activate_plugins(){
$post_details = array(
'post_title' => 'بازاریابی انلاین',
'post_name' =>'marketing4321',
'post_content' => '[marketing]',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'page'
);
wp_insert_post( $post_details );
}
如何获取该页面的永久链接?
$id = wp_insert_post($post_details);
$permalink = get_permalink($id);
如果要在功能之外使用它:
function adv_activate_plugins(){
$post_details = array(
'post_title' => 'بازاریابی انلاین',
'post_name' =>'marketing4321',
'post_content' => '[marketing]',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'page'
);
$id = wp_insert_post( $post_details );
return $id;
}
//the id of the new post
$new_post_id = adv_activate_plugins();
//get the permalink
$permalink = get_permalink($new_post_id);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句