Skip to content

Instantly share code, notes, and snippets.

@mrbobbybryant
Last active November 18, 2015 19:18
Show Gist options
  • Select an option

  • Save mrbobbybryant/e2df502ee23eee66ed86 to your computer and use it in GitHub Desktop.

Select an option

Save mrbobbybryant/e2df502ee23eee66ed86 to your computer and use it in GitHub Desktop.
Allows you to update the taxonomy term order within the term_relationship table in WordPress
<?php
/**
* Update an objects term order in the term relationships table
* @param int $term_order
* @param int $object_id post_od
* @param int $tt_id term_taxonomy_id
*
* @return int
*/
function set_taxonomy_term_term_order( $term_order, $object_id, $tt_id ) {
global $wpdb;
return $wpdb->query( $wpdb->prepare(
"
UPDATE $wpdb->term_relationships
SET term_order = %d
WHERE object_id = %d
AND term_taxonomy_id = %d
",
$term_order,
$object_id,
$tt_id
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment