115 reputation
5
bio website
location Hong Kong
age
visits member for 1 year, 9 months
seen Nov 5 '12 at 2:06

Oct
18
awarded  Popular Question
Oct
18
comment Insert an image into a post by API
get_post_meta( $post_id, '_thumbnail_id', true ) just return the attachment ID, I tried to use wp_get_attachment_url(get_post_meta( $post_id, '_thumbnail_id', true )) to get the attachment url by its id. Finally it works. Thanks
Oct
18
accepted Insert an image into a post by API
Oct
18
comment Insert an image into a post by API
Sorry, I still can't get it to work. I will try it later and update the status. Thanks for your help, I will mark your answer as accepted later. Upvoted
Oct
18
comment Insert an image into a post by API
Sorry I got Fatal error: Call to undefined function add_filter() in /var/www/wp/wp-includes/functions.php on line 3636 when I placed whole snippet in the end of functions.php
Oct
18
comment Insert an image into a post by API
I have put the function insert_img_to_post into function.php, but where should add_filter( 'the_content', 'insert_img_to_post', 20 ); to be placed?
Oct
18
comment Insert an image into a post by API
I think inserting the image to the begining of the content. Thanks
Oct
18
comment Insert an image into a post by API
Yes, you are right, I want to insert the image into the body of the content.
Oct
18
comment Insert an image into a post by API
Thanks for the code, I test that if I use your code, there are none image insert to post; On the other hand, if I put update_post_meta under the line of $attach_id, I will replaced the featured image.
Oct
18
awarded  Editor
Oct
18
revised Insert an image into a post by API
added 50 characters in body
Oct
18
asked Insert an image into a post by API
Oct
18
awarded  Supporter
Oct
17
awarded  Scholar
Oct
17
accepted Can I call a custom plugin with a direct URL
Oct
11
awarded  Student
Oct
11
asked Can I call a custom plugin with a direct URL