tags:

views:

29

answers:

2

I'm trying to set my blog up where every time a post is made (or updated, but only on the most recent post), it automatically saves the post title and url to a text file on the server. This is so that I can display a "latest on the blog" widget on other non-blog parts of my site. Does anyone know which file handles the operations I'm talking about, or other ways to accomplish this?

Thanks in advance!

+1  A: 

I would suggest that the best way to go about it is to write a small WP plugin, because any changed you will make to the core will be lost during WP upgrades. Catching the new post event in a simple WP plugin should be fairly simple.

This should help you get started: http://codex.wordpress.org/Writing_a_Plugin

Sabeen Malik
+1  A: 

As Sabeen said, it's much better to perform this logic as a plugin rather than modifying the core files. That's what the plugin API is there for.

You'll probably want to use the pre_post_update action for your plugin; as such.

// hook the pre_post_update action to call ppu_callback()
// right before a post is updated
add_action( 'pre_post_update', 'ppu_callback' );

function ppu_callback( $postid ) {
  // use the $postid to retrieve the post's info
  // and perform whatever logic you need to here
}

http://codex.wordpress.org/Plugin_API http://codex.wordpress.org/Function_Reference

jay.lee
Thanks! Worked perfectlay. (The "lay" was on purpose...)
motionman95