edited_{$taxonomy}

最后更新于:2021-11-26 09:02:26

do_action( “edited_{$taxonomy}”, int $term_id, int $tt_id )

Fires after a term for a specific taxonomy has been updated, and the term cache has been cleaned.

参数

$term_id

(int)
Term ID.

$tt_id

(int)
Term taxonomy ID.

源文件

文件: gc-includes/taxonomy.php

View on Trac

add_action( 'edited_custom_taxonomy', 'custom_term_slug_edit_success', 10, 2 );

/**
 * Custom redirect on taxonomy term update, keeps users on the term page for additional updates
 *
 * @param $term_id
 * @param $tt_id
 */
function custom_term_slug_edit_success( $term_id, $tt_id ) {
  
    // Get the taxonomy slug.
    $term = get_term( $term_id );
    $tax_slug = $term->taxonomy;
    
    // Setup the redirect URL.
    $tax_param = '&taxonomy=' . $taxonomy_slug;
    $term_param = '&tag_ID=' . $term_id;
    $notice_param = '&notice=success';
    $redirect_url = admin_url( 'edit-tags.php?action=edit' . $tax_param . $tag_param . $notice_param );

    // Redirect with new query strings.
    gc_safe_redirect( $redirect_url );
    exit;

}

<?php 
add_action( 'edited_custom_taxonomy', 'custom_term_slug_edit_success', 10, 2 );

/**
 * Custom redirect on taxonomy term update, keeps users on the term page for additional updates
 *
 * @param $term_id
 * @param $tt_id
 */
function custom_term_slug_edit_success( $term_id, $tt_id ) {
  
    // Get the taxonomy slug.
    $term = get_term( $term_id );
    $tax_slug = $term->taxonomy;
    
    // Setup the redirect URL.
    $tax_param = '&taxonomy=' . $taxonomy_slug;
    $term_param = '&tag_ID=' . $term_id;
    $notice_param = '&notice=success';
    $redirect_url = admin_url( 'edit-tags.php?action=edit' . $tax_param . $tag_param . $notice_param );

    // Redirect with new query strings.
    gc_safe_redirect( $redirect_url );
    exit;

}
?>