Add a custom variable to query page object

I updated my question with a partial answer to this problem. By adding an underscore ‘_’ before the name of the meta field it allows you to add meta data without it creating an editable custom field on the page edit screen. update_post_meta( get_queried_object()->ID, ‘_term_id’, $meta_term_id);

add links to list of post terms

Then try to add foreach ( $arr_terms as $terms_links ) { if(!empty($terms_links)) { echo ‘<a href=”#”>’ . $terms_links . ‘</a>’;  } } That checks if the $terms_links is empty, and if so it wont print it out.

Saving custom term value to the database in new table

short exmaple how i do it… (tables naming not really correct.) in this example i am trying to save _description $_POST variable. add_action ( ‘edited_term’, ‘custom_edited_term’, 10, 3); function custom_edited_term($term_id, $tt_id, $taxonomy){ if ( defined(‘DOING_AJAX’) || defined(‘DOING_CRON’) ) return; $_POST = stripslashes_deep($_POST); if (isset($_POST[‘_description’]) && trim($_POST[‘_description’]) != ”){ update_term_meta($term_id, ‘_description’, trim($_POST[‘_description’])); } else { delete_term_meta($term_id, … Read more

Custom order of taxonomy using wp_get_object_terms and woocommerce_term_meta

I solved this by passing the array of terms into a sorting function. The array is passed by reference so nothing needs to be returned: function sort_object_terms(&$terms) { global $wpdb; // First get an array of just the term IDs $term_ids = array_map(function($term) { return (int)$term->term_id; }, $terms); // Now get the order value for … Read more

how to display child terms with parent terms in custom taxonomy?

Have just tweaked your code to achieve what you need. See, if this works for you – $taxonomyName = “age”; $parent_terms = get_terms($taxonomyName, array(‘parent’ => 0, ‘orderby’ => ‘slug’, ‘hide_empty’ => false)); echo ‘<ul>’; foreach ($parent_terms as $pterm) { $terms = get_terms($taxonomyName, array(‘parent’ => $pterm->term_id, ‘orderby’ => ‘slug’, ‘hide_empty’ => false)); foreach ($terms as $term) … Read more

How to filter a taxonomy meta field to the ‘single_term_title’ filter hook

Solved the issue by passing the term_name as a parameter to the callback function to the filter. function bn_term_title( $term_name ) { $term_types = get_term_by( ‘name’, $term_name, ‘tax_1’ ); if( $term_types->taxonomy === ‘tax_1’ ) { if( get_locale() === ‘bn_BD’ ) return get_term_meta( $term_types->term_id, ‘tax1_bn’ ); else return $term_name; } $term_categories = get_term_by( ‘name’, $term_name, ‘tax_2’ … Read more