Showing custom taxonomy column in taxonomy category listings immediately after create category

What is happening is that: the page /wp-admin/edit-tags.php uses $_GET[‘taxonomy’] and /wp-admin/admin-ajax.php, fired when we create a new term, uses $_POST[‘taxonomy’] To solve it, use $_REQUEST in manage_my_category_columns(). It will cover both GET and POST: if ( !isset( $_REQUEST[‘taxonomy’]) || $_REQUEST[‘taxonomy’] != ‘products’ ) Related Q&A: WP List Table custom quick edit box – post … Read more

How to output hierarchical taxonomy path, with only the deepest term assigned?

Use get_the_terms to fetch the post’s term, then use get_ancestors to get an array of that term’s parent IDs. $tax = ‘category’; $terms = get_the_terms( get_the_ID(), $tax ); if( $terms && ! is_wp_error( $terms ) ){ // check for and output any ancestors $ancestors = array_reverse(get_ancestors( $terms[0]->term_id, $tax )); if( $ancestors ){ foreach( $ancestors as … Read more

How to show the category filter that’s shown on the ‘All post’ pages on a custom post type page in the admin area?

If your post type supports the category taxonomy, then that drop-down menu would be displayed by default: register_post_type( ‘my_cpt’, [ ‘public’ => true, ‘taxonomies’ => [ ‘category’ ], // here, the post type supports the `category` taxonomy //… ] ); Otherwise, or for custom taxonomies, you can use the restrict_manage_posts hook and wp_dropdown_categories() to add … Read more

Custom taxonomy is crashing Gutenberg

Changing the taxonomy name fixes. I’ll wager the guess that having it called ‘type’ was conflicting with the Gutenberg js. $args = array( ‘labels’ => $labels, ‘hierarchical’ => false, ‘public’ => true, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘show_in_nav_menus’ => true, ‘show_tagcloud’ => false, ‘show_in_rest’ => true, ); register_taxonomy( ‘resource-type’, array( ‘resource’ ), $args );

List a current posts’ taxonomy terms in a widget in WordPress

This is a simple conversion of the Taxonomy terms list plugin to a widget: class WPSE_5394_Widget extends WP_Widget { public function __construct() { parent::__construct( ‘wpse5394_widget’, ‘Taxonomy Terms List’ ); } public function widget( $sidebar_args, $widget_options ) { if ( ! is_single() ) { // I don’t think we can display anything sensible on a page … Read more

How to list 2 taxonomy terms for a post, based on their hierarchy

I managed to hack this together using wp_get_object_terms. The ‘orderby’ => ‘term_id’ was most helpful. It’s probably not the best method, but seems to work fine. Because the child terms (suburbs) are always created after the parent terms (Cities), they will always have a higher ID. <?php $terms = wp_get_object_terms($post->ID, ‘location’, array(‘orderby’ => ‘term_id’, ‘order’ … Read more

WordPress as thesaurus/dictionnary: what approach?

I would create custom post types and custom taxonomy, taking the standard “Posts” out of the loop. You can then have two separate Taxonomies (Tag systems) for synonyms and antonyms. http://codex.wordpress.org/Post_Types http://codex.wordpress.org/Taxonomies You can then use a plugin like Gravity Forms to have your users register for the site and submit their words, which can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)