Function Reference: geodir_create_page
Summary
Create a page.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $current_user
- (object) (required) Current user object.
- Default: None
Package
GeoDirectory
Parameters
- $slug
- (string) (required) The page slug.
- Default: None
- $option
- (string) (required) The option meta key.
- Default: None
- $page_title
- (string) (required) The page title.
- Default: None
- $page_content
- (string) (required) The page description.
- Default: None
- $post_parent
- (int) (required) Parent page ID.
- Default: None
- $status
- (string) (required) Post status.
- Default: None
Change Log
Since: 1.0.0
Source File
geodir_create_page() is located in geodirectory-admin/admin_functions.php [Line: 6093]
Source Code
function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') { global $wpdb, $current_user; $option_value = get_option($option); if ($option_value > 0) : if (get_post($option_value)) : // Page exists return; endif; endif; $page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", array($slug) ) ); if ($page_found) : // Page exists if (!$option_value) update_option($option, $page_found); return; endif; $page_data = array( 'post_status' => $status, 'post_type' => 'page', 'post_author' => $current_user->ID, 'post_name' => $slug, 'post_title' => $page_title, 'post_content' => $page_content, 'post_parent' => $post_parent, 'comment_status' => 'closed' ); $page_id = wp_insert_post($page_data); add_option($option, $page_id); }