Displaying the category name of a custom post type
So this is what I needed: <?php $terms = get_the_terms( $post->ID , ‘board’ ); foreach ( $terms as $term ) { echo $term->name; } ?>
So this is what I needed: <?php $terms = get_the_terms( $post->ID , ‘board’ ); foreach ( $terms as $term ) { echo $term->name; } ?>
s_ha_dum’s answer didn’t work for me, but this did: /** * Completely disable term archives for this taxonomy. * @param string $taxonomy WordPress taxnomy name */ function kill_taxonomy_archive($taxonomy){ add_action(‘pre_get_posts’, function($qry) { if (is_admin()) return; if (is_tax($taxonomy)){ $qry->set_404(); } } ); }
You can get the term object of the category you’re viewing with get_queried_object(). That will contain the slug. $term = get_queried_object(); echo $term->slug;
You can use a {$taxonomy}_edit_form_fields action hook to add html to the term edit table. In that HTML you can remove description textarea and add tinymce editor add_action(“{$taxonomy}_edit_form_fields”, ‘add_form_fields_example’, 10, 2); function add_form_fields_example($term, $taxonomy){ ?> <tr valign=”top”> <th scope=”row”>Description</th> <td> <?php wp_editor(html_entity_decode($term->description), ‘description’, array(‘media_buttons’ => false)); ?> <script> jQuery(window).ready(function(){ jQuery(‘label[for=description]’).parent().parent().remove(); }); </script> </td> </tr> <?php … Read more
I’m assuming that you don’t want to set different labels for these taxonomies in the first place – you didn’t specifically mention that you can’t, but I’m assuming the thought occurred to you. Just in case it didn’t, from your code: register_taxonomy(“product_cat”, “product”, array( “labels” => array( “name” => “Categories”, Changing “Categories” to “Product Categories” … Read more
My recommendation would be to place the code that defines your custom taxonomies into a plug-in and activate the plug-in site wide. This will cause the new taxonomies to become active on all the sites in your network.
Get rid of the filter that you have. Make sure that you use ‘rewrite’ => array( ‘hierarchical’ => ‘true’ ) in your register_taxonomy() function. Don’t forget to flush the rewrite rules. See this page for more info: Codex
It is possible to register a taxonomy without associating a post type by passing null as your argument for the $object_type. Unfortunately, this means that you will still need to associate an object type (post type) to your taxonomy later in order to use it. register_taxonomy( ‘aprwc_rating_criteria’, null, $args ); From the documentation: Setting explicitly … Read more
I would go for custom nav menu walker… //define the custom post type and custom taxonomy define(“MENU_CPT”, “people”); define(“MENU_CT”, “club”); //custom function for selecting posts based on a term function get_posts_by_term($term_id, $post_type=MENU_CPT, $taxonomy=MENU_CT) { $args = array( ‘posts_per_page’ => -1, ‘post_type’ => $post_type, ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomy, ‘field’ => ‘id’, ‘terms’ => … Read more
For a function that enqueues scripts, the action hook you use should actually be “wp_enqueue_scripts” for the front of the site, and “admin_enqueue_scripts” for the admin side of things. This is the proper time to enqueue scripts. While you can technically do it anytime before wp_head, this is the best place because it’s pretty much … Read more