tags:

views:

200

answers:

1

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 http://www.example.com/uncategorized/1. So the problem is, if i post through wordpress admin panel, GUID of the post is http://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 http://www.example.com?p=1

How can i do it ? Please point me out. Thank you.

A: 

I think the short answer is to not worry about the GUID of a post in WordPress. Here's a thread discussing the (in)validity of a post's GUID: http://www.mail-archive.com/[email protected]/msg12434.html

If you ever need a post's URL, you should use the get_permalink() function. This will always respect your current permalink structure, and is the safest way to get post's URL

bigdawggi