WP_Insert_Post and GUID
-
Hello,
I have a posting form at my theme. I used wp_insert_post there. My code looks like this
$post = array( 'ID' => '', 'post_author' => $post_author, 'post_category' => $post_category, 'post_content' => $post_content, 'post_title' => $post_title, 'post_status' => 'publish', ); $post_id = wp_insert_post($post); $fullpost = get_post($post_id); wp_redirect($fullpost->guid);
Everything works fine. But when it’s inserted to the database, at the GUID field, the entry format is like this permalinks_structure/id. So if my permalinks_structure is like /category/id , it become like https://www.example.com/uncategorized/1. So the problem is, if i post through wordpress admin panel, GUID of the post is https://www.example.com?p=1 . So my post database GUID become mess, because if i want to change permalinks_structure , the post which becomes from outside form will follow the structure.
What I want to do is, I want to get the GUID like that I posted through admin panel which is https://www.example.com?p=1
How can i do it ? Please point me out. Thank you.
- The topic ‘WP_Insert_Post and GUID’ is closed to new replies.