Hi, thank you for coming back.
I am not planning to add sticky tags. If possible I prefer changing the term_order for newly created terms, which is much simpler.
I assume the submitted post gets edited on the editor, where new tags can be added. The next code can be used to have new tags always have a term_order of 4, so they are always below the first three terms in the order.
The code can be added to your own plugin or to the index.php of your theme, preferably a child theme.
// Edit post screen, set term_order higher than 0, so it's not at the top.
function my_customtaxorder_add_term_order( $term_id = 0, $tt_id = 0, $taxonomy = '' ) {
if ( isset($_POST['action']) && $_POST['action'] == 'editpost' ) {
if ( $term_id == 0 ) {
return;
}
$term = get_term( $term_id, $taxonomy );
if ( ! is_object( $term ) ) {
return;
}
customtaxorder_set_db_term_order( $term_id, 4, $taxonomy );
}
}
add_action( 'create_term', 'my_customtaxorder_add_term_order', 99, 3 );
Does this work for you?
(And yes, the editor mangles all of this).
-
This reply was modified 3 months, 3 weeks ago by Marcel Pol.