Custom order categories in admin dashboard

Use the get_terms_args hook and modify the orderby argument, like so: add_filter( ‘get_terms_args’, ‘my_sort_terms’, 10, 2 ); function my_sort_terms( $args, $taxonomies ) { $args[‘orderby’] = ‘description’; return $args; } Possible values for this argument are listed in the codex.

weekly archive for custom category

I read the readme.txt file of Archives for a category WordPress plugin. The plugin author has stated following limitation on it. Limitations This plugin does not work for weekly archives. The list with archive links is correct, but the links themselves do not include the category. So when used, WordPress will not filter the resulting … Read more

Insert Into Sub-child Menu

Check that you actually have categories before creating the list, and move the lines that echo the <ul> inside the conditional. $categories = get_the_category(); if (!empty($categories)) { foreach($categories as $category){ $parent = $category->parent; if($parent != 0){ echo ‘<ul style=”background:#000″>’; wp_list_categories(“child_of={$parent}&title_li”); echo ‘</ul>’; } } } This will generate multiple lists, not just one. Here is … Read more

New Theme creation

I found Ian Stewart‘s Theme Development tutorial a wonderful one to start from the scratch with a very little knowledge on WordPress. How To Create a WordPress Theme: The Ultimate WordPress Theme Tutorial Hope the explanation there could help you a lot to understand which code block’s for what. So you can modify yours as … Read more

Show Featured products in product category pages

I just double checked and WooCommerce runs the product category description through the_content filters, which means that it should run shortcodes. WooCommerce has plenty of shortcodes, see their documentation Including featured products: [featured_products per_page=”12″ columns=”4″] The downside to that is that the featured products might not all be from that specific category. You didn’t mention … Read more

Show Different Custom Menu on Different Category Pages

Add a new menu called category-menu: if( function_exists( “wp_nav_menu’ ) ) { add_theme_support( ‘nav-menus’ ); register_nav_menus( array( ‘primary-menu’ => __( ‘Primary Menu’, ‘woothemes’ ) )); register_nav_menus( array( ‘top-menu’ => __( ‘Top Menu’, ‘woothemes’ ) )); register_nav_menus( array( ‘category-menu’ => __( ‘Category Menu’, ‘woothemes’ ) )); } And output it with the conditional is_category(): if( function_exists( … Read more

How to get category name from URL and pass to a template

Rather than creating pages and assigning a template, I would use the category_template filter to load a specific template for all those particular categories. In this example I use a hardcoded array, but this could be adapted to load an option which stores the category slugs you want the template applied to. function wpa_category_template( $templates=”” … Read more

Set the default category of an attachment

To solve the problem 1, you could hook to add_attachment and edit_attachment hook. add_action(‘add_attachment’, ‘wpse_set_attachment_category’); add_action(‘edit_attachment’, ‘wpse_set_attachment_category’); function wpse_set_attachment_category( $post_ID ) { // if attachment already have categories, stop here if( wp_get_object_terms( $post_ID, ‘category’ ) ) return; // no, then get the default one $post_category = array( get_option(‘default_category’) ); // then set category if default … Read more