Title: Auto creation of posts using wp_insert_post function
Last modified: August 20, 2016

---

# Auto creation of posts using wp_insert_post function

 *  [clockticks](https://wordpress.org/support/users/clockticks/)
 * (@clockticks)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/auto-creation-of-posts-using-wp_insert_post-function/)
 * So I just found the function wp_insert_post. The thing is, I know little PHP 
   and not sure how I can start to tie this into what I want to do.
 * I have a python script that inserts a list of urls and titles each day into a
   file on my server. I want to be able to insert these urls and titles into the
   mysql db a couple times a day.
 * It looks like I need to somehow tie this into using the wp_insert_post function
   in PHP somehow. What I think I need to do is have a PHP script or something with
   that function read from this file that has my data, I’m not totally sure.
 * How should I go about attacking this, can the community please provide me with
   some guidance as to how they would go about doing this?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Andrew Bartel](https://wordpress.org/support/users/andrew-bartel/)
 * (@andrew-bartel)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/auto-creation-of-posts-using-wp_insert_post-function/#post-3153650)
 * You’d want to set up a cron job that runs a function. Example below:
 *     ```
       add_action('my_action', 'Actual_Function_That_Runs_Insert');
   
       function my_activation() {
       	if ( !wp_next_scheduled( 'my_action' ) ) {
       		wp_schedule_event( time(), 'daily', 'my_action');
       	}
       }
       add_action('wp', 'my_activation');
   
       function Actual_Function_That_Runs_Insert()
       {
       // run insert
       }
       ```
   
 * This will set up a cron job to runs daily in WordPress. You can’t do them the“
   standard” way in cpanel (or actual linux if you’re boss) because of the mod rewrite
   in the htaccess file, or at least I never have been able to get them to work.
   [Cron View](http://wordpress.org/extend/plugins/cron-view/) is a handy plugin
   to see if your job was scheduled successfully.
 *  Thread Starter [clockticks](https://wordpress.org/support/users/clockticks/)
 * (@clockticks)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/auto-creation-of-posts-using-wp_insert_post-function/#post-3153655)
 * I really can’t just run it in cron? I’m not using a control panel at all other
   than logging into the wp admin page, it’s a centos box I have root on.
 *  [Andrew Bartel](https://wordpress.org/support/users/andrew-bartel/)
 * (@andrew-bartel)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/auto-creation-of-posts-using-wp_insert_post-function/#post-3153663)
 * If you can get it to work please post in this thread and let me know what you
   did. I’ve written a million cron jobs but have never gotten one to work on a 
   WP site. Considering the amount of plugins out there for managing cron jobs in
   WordPress, I don’t think we’re the first people to run into this problem.
 *  [fonglh](https://wordpress.org/support/users/fonglh/)
 * (@fonglh)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/auto-creation-of-posts-using-wp_insert_post-function/#post-3153700)
 * I haven’t tried it, but I don’t see why you can’t run any script you want that
   inserts entries into the wp_posts table with cron.
 * Andrew’s method would be the more WordPress way.
 * Note that cron and wp-cron are not the same.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Auto creation of posts using wp_insert_post function’ is closed to new
replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [wp_insert_post](https://wordpress.org/support/topic-tag/wp_insert_post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [fonglh](https://wordpress.org/support/users/fonglh/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/auto-creation-of-posts-using-wp_insert_post-function/#post-3153700)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
