Posted by brant : 2009-11-18 at 1:54 pm

If you plan to use wordpress as an aggregator of some sort, you'll need to learn how to post automatically with PHP.  It's actually fairly simple to get started.   Wordpress has the post function listed, so I will just basically copy and paste their code below:


// include the wordpress classes
	include("wp-blog-header.php");

// Create post object
  $my_post = array();
  $my_post['post_title'] = 'My post';
  $my_post['post_content'] = 'This is my post.';
  $my_post['post_status'] = 'publish';
  $my_post['post_author'] = 1;
  $my_post['post_category'] = array(8,39);

// Insert the post into the database
  wp_insert_post( $my_post );
// That's it!

As you can see, names are numbered, as are categories.  That can make things tricky when you want to make it look like you have 10 users posting to 15 different categories.  Now let's say you have additional custom fields you need to add.  How the heck does that work?  I'm glad I asked myself. . .


// include the wordpress classes
	include("wp-blog-header.php");
 update_post_meta(ID, 'image', 'imageurl_goes_here'); 

This is an example of adding an image to the post based on the post ID.  You can add as many meta posts to each post as you wish.

Again, this is the simpliest way to automate posting, like adding an excerpt to each post.  There are lots more things that can be customized in each post submission.



Similar Blogs:
AimStats 2.0 And Then Some
Too Much Time On My Hands

blog comments powered by Disqus