Set a taxonomy as private

You should also set the query_var to false. So your args array should be like this: $args = array( ‘labels’ => $labels, ‘public’ => false, ‘query_var’ => false, ‘rewrite’ => false, ‘hierarchical’ => false, ); Cheers

Convert Custom Post Types to Custom Taxonomies

Here’s the solution that worked for me. I added the below code to a page template (page-test.php) and then created a page called “test,” loaded the page, and all the CPTS were converted to taxonomies. Not sure if this happened when I created the page or when I loaded it… And then I quickly deleted … Read more

Programatically added attribute, set to ‘show on product page’ automatically. Woocommerce [closed]

It actually doesn’t matter because WooCommerce uses this, to display: $values = wc_get_product_terms( $product->id, $attribute[‘name’], array( ‘fields’ => ‘names’ ) ); However, if you don’t set the display to true, you’d have to add this code to your template files. You might have to do other things as well (styling, etc). If you just set … Read more

Call javascript function when category was added via ajax

Recently, I just have the same problem and got the solution. use ajaxSuccess event since we need to reset input when ajax is completed. filter the settings data for specific action and screen. Code: $(document).ajaxSuccess(function(e, request, settings){ var object = $.deparam(settings.data); if(object.action === ‘add-tag’ && object.screen === ‘edit-category’ && object.taxonomy === ‘category’){ //DO RESET Your … Read more

Sorting taxonomy columns by meta value numeric

The code I am posting is a modified and simplified version of yours. I got my solution using your code. /** * Filter WP_Term_Query meta query * * @param object $query WP_Term_Query * @return object */ function filter_terms_clauses( $pieces, $taxonomies, $args ) { global $pagenow, $wpdb; if(!is_admin()) { return $pieces; } if( is_admin() && $pagenow … Read more

Change permalink of post if it belongs to custom taxonomy

You can modify the permalinks using the the_permalink filter and add a rewrite rule using add_rewrite_rule to redirect the new permalinks to the standard post link. function mysite_modify_permalink($url) { global $post; //if taxonomy archive for Series get term $term = is_tax(‘Series’)?get_query_var(‘term’):”; if(empty($term)) { //if no term was found //get all Series terms for current post … Read more

Get taxonomy terms only of the WP_Query current posts

You’d probably do something like this $args = array( ‘post_type’ => ‘product’, ‘product_cat’ => get_queried_object() ); $query = new WP_Query( $args ); $termsInPosts = array(); if ( $query->have_posts() ) { while( $query->have_posts() ) : $query->the_post(); $postTerms = wp_get_post_terms(get_the_ID(), ‘brands’, array(‘fields’ => ‘term_id’)); foreach ($postTerms as $postTerm) if (!in_array($postTerm->term_id, $termsInPosts)) $termsInPosts[] = $postTerm->term_id; endwhile; } $marcas_terms … Read more

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