Is it possible to hook a function when a custom taxonomy term (which is not known beforehand), (preferably custom taxonomy child term) is edited/saved, just like the way we can hook into save_post when a post or page is saved?
What I want to do when the taxonomy term is saved:
function generate_pdf($slug) {
wp_remote_get( etc... );
}
EDIT:
It seems that edit_${taxonomy} is the thing that I need, but I can't seem to push the $term_slug into the function:
function pdf_save_magazine($term_id, $tt_id, $taxonomy) {
$term = get_term($term_id, $tt_id);
$term_slug = $term->slug;
wp_remote_get(
'http://url-that-saves-pdf.com/?print='.$term_slug,
array(
'blocking' => false,
'timeout' => 1,
'httpversion' => '1.1'
)
);
}
add_action( 'edit_auteur', 'pdf_save_magazine', $term_id, $tt_id, $taxonomy );
In WordPress, you can create (or “register”) a new taxonomy by using the register_taxonomy() function. Each taxonomy option is documented in detail in the WordPress Codex. After adding this to your theme's functions. php file, you should see a new taxonomy under the “Posts” menu in the admin sidebar.
Add the following code into the “functions.$selected = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids')); $hierarchical = $tax->hierarchical; ?>
Displaying Custom Taxonomy Terms in a Widget Using Code First, you need to add this code in your theme's functions. php file or a site-specific plugin. add_filter( 'widget_text' , 'do_shortcode' );
To answer my own question:
This works:
function pdf_save_magazine($term_id, $tt_id, $taxonomy) {
$term = get_term($term_id, $taxonomy);
$term_slug = $term->slug;
wp_remote_get(
'http://url-that-saves-pdf.com/?print='.$term_slug,
array(
'blocking' => false,
'timeout' => 1,
'httpversion' => '1.1'
)
);
}
add_action( 'edit_term', 'pdf_save_magazine', 10, 3 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With