WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am not able to get the data of post which i inserted by


now i want to get the tags which i stored by

'tags_input' => array('thread_tag' => $tags)

and i also upload an image of this post as attachment, so could you please tell me how to retrieve the attachment?

share|improve this question

You can use:

$post_id = wp_insert_post($args);

to get the ID of the inserted post. You can try this:

   $terms = wp_get_object_terms($post_id, 'thread_tag');

to get the terms from your post with $post_id. You can check out the Codex:


You can then use get_children()

$args = array(
'post_mime_type' => 'image',
'post_parent' => $post_id,
'post_type' => 'attachment'

$attachments = get_children( $args );

to fetch the attachments for this post. More on the Codex page:



To set the terms in the 'thread_tag' taxonomy for a given $post_id



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.