<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Anthology of Ideas &#187; wordress</title>
	<atom:link href="http://anthologyoi.com/tag/wordress/feed" rel="self" type="application/rss+xml" />
	<link>http://anthologyoi.com</link>
	<description>Anthology of Ideas is an archive of thoughts and form.</description>
	<lastBuildDate>Sat, 03 Mar 2012 11:16:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Insert an image into a WordPress Post with a plugin.</title>
		<link>http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html</link>
		<comments>http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html#comments</comments>
		<pubDate>Thu, 15 Oct 2009 20:15:42 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[wordress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/blogish/asides/insert-an-image-into-a-wordpress-post-with-a-plugin.html</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>So in a project I&#8217;m working on I need to use a normal form to insert a post into the database. My client wanted the form to also add an image to the post. Furthermore, the image must be inserted using normal WordPress methods. The code below is the minimum required to insert an image into the database and attach it to a specific post.</p>
<p><pre class="brush: php">include_once(ABSPATH.&#039;/wp-admin/includes/media.php&#039;);
	include_once(ABSPATH.&#039;/wp-admin/includes/file.php&#039;);
	include_once(ABSPATH.&#039;/wp-admin/includes/image.php&#039;);
	
//	$id is the id of the post being inserted
//	$name is actually the name of the form input that uploaded the file so WP can access it using $_FILE[$name]
	media_handle_upload($name,$id);</pre></p>
<p>If you are inserting a new post, it makes sense to have the line <span class="inline-code">$id = wp_insert_post($post_data);</span> before this.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

