add an image field to wordpress category

I had some trouble saving custom taxonomy fields, which I resolved in this WPSE post. I was using the options table to save my data, but the same solutions may apply for you too. Firing callbacks attached to create_{taxonomy} and edited_{taxonomy} were part of the solution.

Indenting Category list

$args = array( ‘type’ => ‘post’, ‘hide_empty’ => 0, ‘hierarchical’ => 1, ‘taxonomy’ => ‘category’, ‘pad_counts’ => false ); $categories = get_categories($args); foreach($categories as $category) { echo ‘<tr>’; if($category->parent != 0){ // If this is a subcategory echo “<td>&nbsp;&nbsp;$category->name</td>”; } else { echo “<td>$category->name</td>”; } echo “<td><input type=”text” name=”$category->cat_ID”/></td>”; echo ‘</tr>’; }

Custom loop by url

You can customise the loop query to get results based on a search term – with $s being the search term; <?php // Post Query $args=array( ‘s’ => $s, ); ?> <?php query_posts($args); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

list taxonomy based on taxonomy

If you are trying to print children of a category, this should be sufficient: <?php wp_list_categories(‘orderby=id&show_count=1&use_desc_for_title=0&child_of=”.$term_id); ?> Details here: http://codex.wordpress.org/Template_Tags/wp_list_categories

Exclude Category From Home Page, Display Posts on It’s Own Page?

Rather than performing a separate query, to exclude a category (or any other taxonomy) term, you can hook into pre_get_posts: add_action(‘pre_get_posts’, ‘wpse41820_exclude_cat_from_front_page’); function wpse41820_exclude_cat_from_front_page( $query ){ if( $query->is_main_query() && is_front_page() ){ $tax_query = array(array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array( 57 ), ‘operator’ => ‘NOT IN’ )); $query->set(‘tax_query’,$tax_query); } return $query; } … Read more

Way to show content of a post, but if exceeds character limit revert to excerpt?

replace the_content(); with echo wpse_limit_content(); function wpse_limit_content() { $content = $post->post_content; $MAX_LENGTH = 100; if ( strlen( $content ) <= $MAX_LENGTH ) return apply_filters(‘the_content’, $content ); $s2 = substr( $content, 0, $MAX_LENGTH ); $s3 = preg_split( “/\s+(?=\S*+$)/”, $s2 ); $s4 = $s3[0]; return apply_filters( ‘the_excerpt’, $s4 ); } If the string is to long it … Read more