Display Custom Taxonomy Terns ordered by meta_value

Assuming the position field is filled with numbers to give order: have a look at ksort. <?php $terms = get_terms(‘brands’); // Let’s create our own array and then reorder it $order_terms = array(); foreach( $terms as $term ) { $position = set_up_the_position_meta_here; $order_terms[$position] ='<h2>’.$term->name.'</h2>’; } // now lets reorder the array based on keys (position) … Read more

Manipulating cookie on specific taxonomy archive page

After googling around I found the correct way to do it by using the ‘wp’ hook if (is_tax(‘term-country’)) add_action(‘wp’, ‘my_setcookie’); // my_setcookie() set the cookie on the domain and directory WP is installed on function my_setcookie(){ $path = parse_url(get_option(‘siteurl’), PHP_URL_PATH); $host = parse_url(get_option(‘siteurl’), PHP_URL_HOST); $expiry = strtotime(‘+1 month’); setcookie(‘location’, ‘my_cookie_value_3’, $expiry, $path, $host); }

Taxonomies not appearing in columns on dashboard

Call register_taxonomy() with ‘show_admin_column’ => TRUE and WordPress will create your columns automatically. This parameter was added in version 3.5. You don’t need a custom filter anymore. I have written a small plugin to demonstrate this case: t5-taxonomy-location. This is the registration code: protected function register_taxonomy() { $this->set_labels(); $args = array ( ‘labels’ => $this->labels, … Read more

Is there a way of storing posts and pages under the same hierarchy?

Yes, a custom taxonomy is the best way to achieve this. For a cat breeder site I’ve set a taxonomy for colors (in german: Farbe): register_taxonomy( ‘farbe’, array( ‘post’, ‘page’ ), array( ‘hierarchical’ => false, ‘label’ => ‘Farbe (Fell)’, ‘query_var’ => ‘farbe’, ‘rewrite’ => array(‘slug’ => ‘farbe’) ) ); Note the third parameter array( ‘post’, … Read more

Approach for saving a product attribute values with a custom UI in a woocommerce+dokan set up [closed]

Actually, this ended up being straight forward. Displaying the drop down I used this line to get the list of terms for my pa_condition taxonomy: $attr_condition = get_terms( array( ‘taxonomy’ => ‘pa_condition’, //empty string(”), false, 0 don’t work, and return empty array ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => false, //can be 1, ‘1’ … Read more

How to show taxonomy meta on frontpage?

Over at Google+ I posted the same question and credits go to Alexander Conroy for coding up the correct solution: /* List all blogs, source example 2: http://codex.wordpress.org/Function_Reference/get_terms#Examples * * credits Alexander Conroy – https://plus.google.com/u/0/113053085239726972447 */ $terms = get_terms(‘blog’, $args); $blog_image_meta = get_option(‘blog_image’); if (!empty($terms)) { foreach ($terms as $term) { $meta = isset($blog_image_meta[$term->term_id]) ? … Read more