[wp-hackers] Custom URL

James Collins james at om4.com.au
Tue Mar 2 03:32:31 UTC 2010


Which version of WordPress are you using?

If you are using pre 3.0, I would use:
http://domain.com/wp-admin/admin-post.php?action=your_unique_action_name
You then hook into this with something like:
add_action('admin_post_nopriv_your_unique_action_name', 'your_handler');

In WordPress 3.0, you would use:
http://domain.com/wp-ajax.php?action=your_unique_action_name
You then hook into this with something like:
add_action('ajax_your_unique_action_name', 'your_handler');
(this new wp-ajax.php file was added in
http://core.trac.wordpress.org/changeset/13527).


You then put your handling code in a your_handler() function.

Using these AJAX hooks means that loading the whole of WordPress is avoided
(ie your WordPress template isn't echo'd/displayed).

If you want to make these URLs look more friendly, then I would use
mod_rewrite in your .htaccess file to rewrite /xmlserver/ to one of the
above URLs.

Regards,

James Collins

OM4 - Website Design and Development


More information about the wp-hackers mailing list