<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>Comments on: Programmatically Creating Posts in WordPress</title>
	<atom:link href="https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/</link>
	<description>Useful Resources For Webmasters</description>
	<lastBuildDate>Sun, 24 May 2026 19:46:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>By: Joe Bhakti Rendeun</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-39135</link>
		<dc:creator><![CDATA[Joe Bhakti Rendeun]]></dc:creator>
		<pubDate>Mon, 19 Aug 2019 01:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-39135</guid>
		<description><![CDATA[you need this in header
&lt;code&gt;
define(&#039;WP_USE_THEMES&#039;, false);
require(&#039;../wp-blog-header.php&#039;);
&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>you need this in header<br />
<code><br />
define('WP_USE_THEMES', false);<br />
require('../wp-blog-header.php');<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-38905</link>
		<dc:creator><![CDATA[Richard]]></dc:creator>
		<pubDate>Sat, 22 Feb 2014 15:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-38905</guid>
		<description><![CDATA[Is it possible to somehow change the post_content conditionally?
Im using a foreach to add multiple posts at once:

$add_pages = array(
				&#039;post_title&#039; =&gt; $new_page,
				&#039;post_content&#039; =&gt; &#039;&#039;, // lets say, if the page_title is &#039;Home&#039;, set the post_content to &#039;Default home page content&#039;
				&#039;post_status&#039; =&gt; &#039;publish&#039;,
				&#039;post_type&#039; =&gt; &#039;page&#039;
			);]]></description>
		<content:encoded><![CDATA[<p>Is it possible to somehow change the post_content conditionally?<br />
Im using a foreach to add multiple posts at once:</p>
<p>$add_pages = array(<br />
				&#8216;post_title&#8217; =&gt; $new_page,<br />
				&#8216;post_content&#8217; =&gt; &#8221;, // lets say, if the page_title is &#8216;Home&#8217;, set the post_content to &#8216;Default home page content&#8217;<br />
				&#8216;post_status&#8217; =&gt; &#8216;publish&#8217;,<br />
				&#8216;post_type&#8217; =&gt; &#8216;page&#8217;<br />
			);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pradeep</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-32857</link>
		<dc:creator><![CDATA[Pradeep]]></dc:creator>
		<pubDate>Mon, 18 Feb 2013 11:33:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-32857</guid>
		<description><![CDATA[Hi..., Is this code creates different pages which have different contents? Please clarify. Because I want to create pages instantly when a surveyor uploads data to database.]]></description>
		<content:encoded><![CDATA[<p>Hi&#8230;, Is this code creates different pages which have different contents? Please clarify. Because I want to create pages instantly when a surveyor uploads data to database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-26596</link>
		<dc:creator><![CDATA[Matt]]></dc:creator>
		<pubDate>Sun, 28 Oct 2012 00:28:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-26596</guid>
		<description><![CDATA[Maybe this one: http://perishablepress.com/user-submitted-posts/]]></description>
		<content:encoded><![CDATA[<p>Maybe this one: <a href="http://perishablepress.com/user-submitted-posts/" rel="nofollow">http://perishablepress.com/user-submitted-posts/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chittagong</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-26570</link>
		<dc:creator><![CDATA[Chittagong]]></dc:creator>
		<pubDate>Sat, 20 Oct 2012 11:28:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-26570</guid>
		<description><![CDATA[Do you know any good plugin that does the creating page thing easily without going into code? Non-programmers like me always seek opportunity to grab plugins to sort out things.]]></description>
		<content:encoded><![CDATA[<p>Do you know any good plugin that does the creating page thing easily without going into code? Non-programmers like me always seek opportunity to grab plugins to sort out things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ANil</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-26487</link>
		<dc:creator><![CDATA[ANil]]></dc:creator>
		<pubDate>Mon, 01 Oct 2012 08:03:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-26487</guid>
		<description><![CDATA[There are lots on plugins that can be used to execute code in post. eg. php exec.]]></description>
		<content:encoded><![CDATA[<p>There are lots on plugins that can be used to execute code in post. eg. php exec.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anilou</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-26483</link>
		<dc:creator><![CDATA[Anilou]]></dc:creator>
		<pubDate>Sat, 29 Sep 2012 15:20:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-26483</guid>
		<description><![CDATA[There is very useful plugin that will help you to create custom form with any kind of fields you want. The plugin is &quot;custom fields&quot;. You can use &quot;custom post types&quot; together with &quot;custom fields&quot;. You will definitely thanks me if you dont know about this plugin. Just try it...]]></description>
		<content:encoded><![CDATA[<p>There is very useful plugin that will help you to create custom form with any kind of fields you want. The plugin is &#8220;custom fields&#8221;. You can use &#8220;custom post types&#8221; together with &#8220;custom fields&#8221;. You will definitely thanks me if you dont know about this plugin. Just try it&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryan</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-20688</link>
		<dc:creator><![CDATA[ryan]]></dc:creator>
		<pubDate>Tue, 31 Jan 2012 14:59:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-20688</guid>
		<description><![CDATA[I found a great tutorial adding post and comment programmatically here&#039;s the link http://www.sutanaryan.com/blog/wordpress/how-to-create-post-and-comment-in-wordpress-programmatically]]></description>
		<content:encoded><![CDATA[<p>I found a great tutorial adding post and comment programmatically here&#8217;s the link <a href="http://www.sutanaryan.com/blog/wordpress/how-to-create-post-and-comment-in-wordpress-programmatically" rel="nofollow">http://www.sutanaryan.com/blog.....mmatically</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Léon</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-20190</link>
		<dc:creator><![CDATA[Léon]]></dc:creator>
		<pubDate>Tue, 25 Oct 2011 14:39:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-20190</guid>
		<description><![CDATA[There is a plugin for it:
http://wordpress.org/extend/plugins/exec-php/]]></description>
		<content:encoded><![CDATA[<p>There is a plugin for it:<br />
<a href="http://wordpress.org/extend/plugins/exec-php/" rel="nofollow">http://wordpress.org/extend/plugins/exec-php/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Léon</title>
		<link>https://www.webmaster-source.com/2010/02/09/programmatically-creating-posts-in-wordpress/#comment-20188</link>
		<dc:creator><![CDATA[Léon]]></dc:creator>
		<pubDate>Tue, 25 Oct 2011 11:52:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3007#comment-20188</guid>
		<description><![CDATA[Check out wp_insert_attachment() at http://codex.wordpress.org/Function_Reference/wp_insert_attachment

Small example from John K @ http://stackoverflow.com/questions/2674069/adding-posts-with-thumbnail-programatically-in-wordpress:
 
    $post_id = wp_insert_post( $my_post_data ); 

    $attach_id = wp_insert_attachment( $attachment, $filename, $post_id );
    $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
    wp_update_attachment_metadata( $attach_id,  $attach_data );]]></description>
		<content:encoded><![CDATA[<p>Check out wp_insert_attachment() at <a href="http://codex.wordpress.org/Function_Reference/wp_insert_attachment" rel="nofollow">http://codex.wordpress.org/Fun.....attachment</a></p>
<p>Small example from John K @ <a href="http://stackoverflow.com/questions/2674069/adding-posts-with-thumbnail-programatically-in-wordpress" rel="nofollow">http://stackoverflow.com/quest.....-wordpress</a>:</p>
<p>    $post_id = wp_insert_post( $my_post_data ); </p>
<p>    $attach_id = wp_insert_attachment( $attachment, $filename, $post_id );<br />
    $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );<br />
    wp_update_attachment_metadata( $attach_id,  $attach_data );</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: www.webmaster-source.com @ 2026-06-09 05:26:16 by W3 Total Cache
-->