Taxonomy Extra Meta [duplicate]

You should be able to do something like this: add_action(“manage_posts_custom_column”, “my_custom_columns”); add_filter(“manage_edit-[POSTTYPE]_columns”, “my_new_columns”); function my_new_columns($columns) { $columns = array( “image” => “Image” ); return $columns; } function my_custom_columns($column) { global $post; if (“ID” == $column) echo $post->ID; elseif (“image” == $column) echo ‘default_value’; } Then you should be able to use $tax_term->image to show it. … Read more

limiting characters shown in taxonomy descriptions

function trunc($phrase, $max_words, $after = null) { $phrase_array = explode(‘ ‘,$phrase); if(count($phrase_array) > $max_words && $max_words > 0) $phrase = implode(‘ ‘,array_slice($phrase_array, 0, $max_words)) . $after; return $phrase; } This function returns the input shortened if there are more words in it than $max_words. You use it like this: $string = “This is a sample … Read more

Can I use $query->set() (in a pre_get_posts() hook) with a custom taxonomy in WP 3?

For what it’s worth, I just gave up on the ‘__not_in’ approach and went with the following somewhat sneaky solution: //Create the exclusion rule $new_tax_query = array( array( ‘taxonomy’ => ‘x_category’, ‘field’ => ‘slug’, ‘terms’ => array(‘y-slug’), ‘operator’ => ‘NOT IN’, ) ); //If there is already a tax_query, ‘AND’ our new rule with the … Read more

How to limit posts to 1 from each term with tax_query?

<?php $categories = array(‘economy’,’the-constitution’,’monetary-policy’,’liberty’); foreach($categories as $category) { $args = array( ‘posts_per_page’ => 1, ‘category_name’ => $category, ‘tax_query’ => array( array( ‘taxonomy’ => ‘highlight’, ‘field’ => ‘slug’, ‘terms’ => array( ‘lead’,’featured’ ), ‘operator’ => ‘NOT IN’ ) ) ); $wpse42358_query = new WP_Query( $args ); while( $wpse42358_query->have_posts() ) : $wpse42358_query->the_post(); // write post stuff here … Read more

How to create a page that lists custom taxonomies with links?

Once you get $taxonomy you can perform further logic: $tax = get_taxonomy( $taxonomy ); if( isset( $tax->has_archive ) && $tax->has_archive == true ) { // do output. archive will be wordpress_url + $taxonomy->name ?> <p> <a href=”https://wordpress.stackexchange.com/questions/43340/<?php echo site_url( $taxonomy->name ); ?>”> <?php echo $tax->labels->name; ?> </a> </p> <?php } This is untested, but you … Read more

How do i change the tags and taxonomies

You can set your tag base differently in the admin area: Settings > Permalinks then at the bottom there is a field for “Tag Base”. Enter “celebrities” in that field and your tag pages will be yoursite.com/celebrities/some-celeb-name. As far as why that is, it’s because the write rules — register_taxonomy does more than just assign … Read more

Alternative for is_taxonomy() to workaround theme’s default sidebar

The function that replaces is_taxonomy() is named taxonomy_exists(). Than there’s also is_tax() and is_tag() that check if the query is for a taxonomy archive page. EDIT $selected_sidebar_replacement == ‘0’ || $selected_sidebar_replacement == ” won’t work. You’re not checking the type. Better do it like this: if ( ! $selected_sidebar_replacement OR emtpy( $selected_sidebar_replacement ) )