Forcing a term/taxonomy on all posts of CPT

Try this: function custom_set_term_to_post(){ $args = array( ‘post_type’ => ‘post’, ); $all_posts = get_posts(); foreach ($all_posts as $key => $post) { $tag_name=”post_tag”; // required tag name $term_list = wp_get_post_terms($post->ID, $tag_name, array(“fields” => “ids”)); if (!empty($term_list)) { // there is already tags; need not do anything continue; } $tag = array( 23 ); // required tag … Read more

Custom taxonomy not showing terms in post area

Seems like its creating some conflict. Can you try with this code ? add_action( ‘init’, ‘country_init’ ); function country_init() { $labels = array( ‘name’ => _x( ‘Countries’, ‘countries’ ), ‘singular_name’ => _x( ‘Country’, ‘countries’ ), ‘search_items’ => _x( ‘Search Countries’, ‘countries’ ), ‘popular_items’ => _x( ‘Popular Countries’, ‘countries’ ), ‘all_items’ => _x( ‘All Countries’, ‘countries’ … Read more

Proper way to update the slug of a taxonomy using register_taxonomy? [duplicate]

register_taxonomy triggers the action registered_taxonomy immediately after it’s registered, which gives you the arguments it was registered with. As long as the taxonomy key doesn’t change, you can hook that action, modify the arguments, then re-register it. function wpd_update_taxonomy_args( $taxonomy, $object_type, $args ){ if( ‘plugin_tax’ == $taxonomy ){ // remove this action so we don’t … Read more

Return the most recently created custom taxonomy

Use get_terms to select that custom taxonomy, ordering by id DESC and returning only one record: $latest_term = get_terms( ‘issuem_issues’, array( ‘orderby’ => ‘id’, ‘order’ => ‘DESC’, ‘number’ => 1, ‘hide_empty’ => false ); This presumes that your WP DB is set up normally, so the highest ID number on the custom taxonomy terms will … Read more

Make child taxonomy categories use a set template

WordPress has a Template Hierarchy – specifically for taxonomies and terms. So what template name you want should follow along the lines of: taxonomy-{$taxonomy}-{$term-slug}.php In your case: taxonomy-classifications-cheese.php This will grab onto the cheese category and display this specific template. I’m not entirely sure if this will also catch child categories ( I would test … Read more

How to display ACF taxonomy checkbox links on WooCommerce product category archive

The issue has been solved. See below for the correct code to display ACF multiple taxonomy links on WooCommerce product category archives. Specifically note the string: $related_terms = get_field(‘quick_links’, $taxonomy . ‘_’ . $term_id); $queried_object = get_queried_object(); $taxonomy = $queried_object->taxonomy; $term_id = $queried_object->term_id; $related_terms = get_field(‘quick_links’, $taxonomy . ‘_’ . $term_id); if( $related_terms ): ?> … Read more