Support » Plugins » How does WordPress takes care of Custom Fields?

  • Resolved bekar09

    (@bekar09)


    Hi everybody,
    I would like to know how wordpress assigns custom fields? Suppose I’m inserting a post through an external script by calling the function ‘wp_insert_post’, and i want to add a custom field for that particular post (say for example the thumbnail url) then how should i go about it? help is much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can update custom fields with update_post_meta().

    Additional info:
    If you’re adding the thumbnail as an attachment to a post you may want to look at the wp_insert_attachment() function in wp-includes/post.php

    Related:
    wp_insert_post()

    Hi MichaelH,
    thanks for the suggestion. can you elaborate how i can pass the thumbnail url as a custom field while calling the function ‘wp_insert_post’ function from an external file? shall i call the function ‘add_post_meta'(<?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?>) after calling the ‘wp_insert_post’ function which returns the POST_ID and passing it to the ‘add_post_meta’? Awaiting your reply.

    shall i call the function ‘add_post_meta'(<?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?>) after calling the ‘wp_insert_post’ function which returns the POST_ID and passing it to the ‘add_post_meta’?

    That sounds right…

    many many thanks sir MichaelH. that worked like a charm.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How does WordPress takes care of Custom Fields?’ is closed to new replies.