Archive for the ‘WP Help’ Category

Display Sub Categories for Each Category

Wednesday, January 14th, 2009

whack

The code that I will explain here will display sub categories only when you are viewing a single category which contains sub categories. This template hack is very simple.

Place this code in your category.php file

<?php
if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo '<h2>';
single_cat_title();
echo '</h2>';
echo '<ul>';
wp_list_categories('orderby=id&hide_empty=1&show_count=0&title_li=&child_of='.$this_category->cat_ID);
echo '</ul>';
}
}
?>

Put this snippet in your category.php template file and It should show sub categories for your parent categories on category pages.

This code simply does the following:

  • Checks whether the current page is a category
  • Checks if the category is parent and has sub categories
  • If it has sub categories, it displays them with a header and unordered list

Customize the wp_list_categories() function

wp_list_categories('orderby=id&hide_empty=1&show_count=0&title_li=&child_of='.$this_category->cat_ID);

By default it displays categories by ID, hides empty categories, and does not show number of posts within each category.

The following code will show post count besides each category

wp_list_categories('orderby=id&hide_empty=1&show_count=1&title_li=&child_of='.$this_category->cat_ID);

Very easy! You can also change hide_empty=1 to hide_empty=0 to display
empty categories (even if they do not have posts, they appear!)

Source from [ http://mywordpressdesign.com/ ]

Developer’s Toolbox

Tuesday, December 9th, 2008

WordPRESS Developer’s Toolbox

Web designers and developers are getting an increasing number of requests from clients for custom theme development, and a growing number of designers are also building their own themes to distribute for free or to sell as premium themes. With all of the WordPress development that is going on, there is a need for an organized collection of resources to educate, inspire and equip developers to improve the quality and efficiency of their work. This post provides all kinds of WordPress-related resources to do just that.

Read full article

Source from : http://www.smashingmagazine.com/

Tricks and Hacks

Monday, December 8th, 2008

10 Useful RSS-Tricks and Hacks For WordPress

By Jean-Baptiste Jung

RSS is one of those technologies that are extremely simple yet extremely powerful. Currently, RSS is the de facto standard for blog syndication, and it is used widely in both personal and corporate settings; for example, in blogs. And because a large percentage of these blogs run on WordPress, we’ll cover in this post some (hopefully) relatively unknown but useful RSS-related tricks and hacks that will help you use RSS in a more effective way — and without unnecessary and chunky WordPress plug-ins.

Let’s take a look at 10 useful, yet rather unknown RSS-tricks for WordPress. Each section of the article presents a problem, suggests a solution and provides you with an explanation of the solution, so that you can not just solve some of your RSS-related problems but also understand what you are actually doing. Thus, you can make sure your WordPress theme remains under your control and is not bloated with some obscure source code.

Read full article

Source from: http://www.smashingmagazine.com