WordPress.org

Ready to get started?Download WordPress

Forums

guid field is empty for attachment in wp_posts (4 posts)

  1. startecommerce2
    Member
    Posted 1 year ago #

    The guid value is always empty for post_type=attachemnt in wp_posts table.

    I am passing the guid correctly, but nothing will be stored in the related field.

    function wp_insert_attachment($object, $file = false, $parent = 0) {
    global $wpdb, $user_ID;

    $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
    'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '',
    'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');

  2. vjpo
    Member
    Posted 1 year ago #

    'guid' => '' means guid must be empty.

  3. startecommerce2
    Member
    Posted 1 year ago #

    'gui' => '' means it should take the default value and the default URL/GUID format

  4. vjpo
    Member
    Posted 1 year ago #

    I don't know the context, where do you use wp_insert_attachment()
    If in custom plugin etc., did you try this example from the Codex?
    'guid' => $wp_upload_dir['url'] . '/' . basename( $filename )

Topic Closed

This topic has been closed to new replies.

About this Topic