Yes it is possible. You can use this action created_term or ‘created_category'( assuming the taxonomy is category )
heres a bit of code to get you started
add_action('created_term', 'post_tax_to_feed', 3);
function post_tax_to_feed( $term_id, $tt_id, $tax ){
if( $tax == 'company' ){
//its our custom taxonomy, insert the post here using wp_insert_post
}
}
for inserting post function, see this page http://codex.ww.wp.xz.cn/Function_Reference/wp_insert_post
This looks great thanks for your help. I think I get how to use wp_insert_post, but do I put the code in the loop?
nevermind, i see this goes into the functions file. Thanks for all your help. I’ll have a hell of time playing with this.
THANK YOU!
So, I spent a night messing with this. I have the following code in my functions.php file:
<?php
add_action('created_term', 'post_tax_to_feed', 3);
function post_tax_to_feed( $term_id, $tt_id, $tax ){
if( $tax == 'company' ){
// Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
);
// Insert the post into the database
wp_insert_post( $my_post );
}
}
?>
Whenever I create a new “company” I get the following error:
http://www.flickr.com/photos/technicallyphl/5275229736/
After refreshing the page the taxonomy gets created but no post is made.
Any ideas on what’s wrong?
oops..something wrong the code I posted
change this line
add_action('created_term', 'post_tax_to_feed', 3);
to
add_action('created_term', 'post_tax_to_feed', 10, 3);
Also, you can use this action too ‘created_company’. In this case no need to check for $tax == and no need of those 2 extra arguments in add_action.
Works like a charm. Thank you very much!