How to truncate the description in the admin panel for a custom taxonomy

One approach is to use JavaScript to add the maxlength attribute to the term description field: function wpse_term_description_attributes() { ?> <script type=”text/javascript”> jQuery(document).ready(function($) { $( ‘.taxonomy-custom_taxonomy_name #description, .taxonomy-custom_taxonomy_name #tag-description’ ).attr( ‘maxlength’, ’20’ ); }); </script><?php } add_action( ‘admin_head’, ‘wpse_term_description_attributes’ ); Replace custom_taxonomy_name with the name of your taxonomy, and customize the value assigned to the … Read more

I cannot get tax_query in get_posts() to work with custom taxonomy

Does your custom post type have the setting publicly_queryable=true? Check the post type in the resulting query to see if it matches your post type. I’m guessing that your post type ‘distribution_centre’ is not being queried for one reason or another. add_filter( ‘posts_request’, ‘dump_request’ );//show the query function dump_request( $query ) { echo “<pre>”; var_dump( … Read more

Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?

After several hours of debugging I have found what caused the problem. Custom taxonomy ‘cadassist_category’ is used for 2 custom post types: product_document and cadassist_file. The posts for taxanomy with ID 653 were of cadassis_file type. And I tried to get posts of product_document type. That is why I got empty array. So if you … Read more

Show posts for current taxonomy

From the above query, it seems that you have passed wrong parameters in tax_query of your query. It should be as follows: ‘tax_query’ => array( array( ‘taxonomy’ => ‘Themes’, //Your custom taxonomy slug ‘field’ => ‘slug’, // this should be field name, not field value ‘terms’ => array(‘environment’), ‘include_children’ => true, ‘operator’ => ‘IN’ ), … Read more

Adding additional taxonomies to wordpress taxonomy page

// 12 – difficulty // destination // get Id current taxonomy $this_term = get_queried_object(); $taxquery = array( ‘posts_per_page’ => 1, ‘post_type’ => ‘packages’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘difficulty’, ‘field’ => ‘id’, ‘terms’ => array( 12 ), ), array( ‘taxonomy’ => ‘destination’, ‘field’ => ‘id’, ‘terms’ => array( $this_term->term_id) // Id … Read more