Advanced Wordpress - Category Based Navigation Instead of Page Based

April 22nd, 2008 - Posted in Development, Wordpress Tips | 4 Comments »

Most Wordpress themes use pages for navigation. This is fine for most single user blogs, but when you want to really start expanding what Wordpress can do, look at using categories for your main navigation.

Both pages and categories are parent - child based, meaning you can create a top level category and then create categories under that main category. For an example of navigation with top level categories and sub categories, go to money.cnn.com/real-estate. Most media, or newspaper based websites use this format, and will really open up the possibilities of your blog.

I would not recommend starting with this format without any content. Make sure you have several posts. This type of blog needs a lot of content. They do not have to be well categorized because you can always change the categories. But if you are starting out and have no content, the first thing to do is organize your categories.

If you want to try out the code, just make a couple parent categories and then make a couple subcategories.

go to your theme folder and open header.php. comment out wp_list_pages(), and add the code below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$defaults = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'show_last_update' => 0,
'style' => 'list',
'show_count' => 0,
'hide_empty' => 0,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_image' => '',
'exclude' => '',
'hierarchical' => true,
'title_li' => '',
'echo' => 1,
'depth' => 1
);
 
wp_list_categories($defaults);

This will list only the top level categories. We do not want to display subcategories until we have clicked on a top level category. You do not need to list all defaults, but you do need to set depth to 1 in order to only show parent categories and set the title_li to nothing.

For more information about wp_list_categories click here

The next step is to display the subcategories when we have chosen a top level category. This is a little tricky because we have to get the category id for the parent category from the first post in that category.

directly after the main navigation make a subnavigation and add this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$cat = get_the_category();
$id = $cat[0]->parent;
 
$defaults = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'show_last_update' => 0,
'style' => 'list',
'show_count' => 0,
'hide_empty' => 0,
'use_desc_for_title' => 1,
'child_of' => $id,
'feed' => '',
'feed_image' => '',
'exclude' => '',
'hierarchical' => true,
'title_li' => '',
'echo' => 1,
'depth' => 1
);
 
if($parents[0]->parent && !is_home())
{
echo "
<ul>". wp_list_categories($defaults) ."</ul>
";
}

The above code first gets the category of the first post in the main category. Then gets the parent id. Then in defaults we set the child_of to the id of the parent. This will get us all children of the main category. We do not want to show any children categories on the home page and if there are no posts we do not want to show any children categories.

That is all that is needed to make a category based navigation. I find it give many more options for your blog. To really customize your blog, you can make separate php files for each category. There is a category hierarchy Wordpress looks for.

  1. category-id.php - id = category id (6)
  2. category.php - this will handle all categories
  3. archives.php - this is probably used the most
  4. index.php - last but not least

Firefox Plugin - Firebug web development recommendation

March 28th, 2008 - Posted in Development | 1 Comment »

In regards to a recent post about firefox plugins, Braxton Beyer recommended another web development plugin called Firebug. I tried it and like it a lot. I like that it is not a toolbar. Firebug is a small button that opens a new window with the editor. The less toolbars the better IMO. Because I’m so use to my standard web developer plugin, I think I will leave it installed for a few weeks while I play with Firebug, but for the stuff I need help with the most (CSS, DOM, javascript functions), Firebug does look a lot better.

firebug web development for firefox

Feel free to send me recommendations for any Wordpress or Firefox plugins that you use.

Simple Explanation of Community Development with Realespace

March 22nd, 2008 - Posted in Development, Web Strategies, realespace | No Comments »

A Widget is not a Widget without a solid API

March 10th, 2008 - Posted in Development, Web Strategies, realespace | No Comments »

A widget or plugin is nothing more then a client interface to your companies API. API stands for Application Programming Interface. The API is a set of functions that your company website offers to remote developers. As the saying goes, build it and they will come. If you provide a good set of programmign tools that allow developers from around the world to access you data, your widgets (or the widgets that developers make for you) will grow far beyond your expectations. If you are thinking about adding benefits and features with a widget,API is for grassroot programming

  • Brainstorm and decide if your data is beneficial to start. If it is, go ahead and move to the next step.
  • Do you think your data can be used outside of your initial plans? if YES, then you definitely need an API, give the world access to your data. An API not only allows you distribute your data, but it also lets you maintain control. Your company builds the API so you control what data is released.
  • Remember, even if nobody makes widgets from your API, you will still have a great framework to build widgets in house.

A good example is the Zillow API. Zillow has tons of data ranging from values of home prices to demographics. When Zillow released their API, they did not have any widgets. I think they still have not made a widget in house, but many developers (including myself) have made widgets based on the Zillow API.

Other API’s:

Website Type Link
yelp.com Area information http://www.yelp.com/developers
yahoo.com yahoo answers http://developer.yahoo.com/answers/
yahoo.com yahoo local http://developer.yahoo.com/local/
yahoo.com shopping http://developer.yahoo.com/shopping/
yahoo.com content analysis http://developer.yahoo.com/…/termExtraction.html
microsoft.com birdseye view of properties http://dev.live.com/…/BirdsEye.htm
google.com traffic overlays http://code.google.com/…Traffic_Overlays
google.com Driving directions http://code.google.com/…Driving_Directions
google.com google base http://code.google.com/apis/base/
google.com mapplets http://code.google.com/…#Mapplets
google.com charts and graphs http://code.google.com/apis/chart/
google.com youtube videos http://code.google.com/apis/youtube/overview.html
google.com open social http://code.google.com/apis/opensocial/
google.com monetizing content http://code.google.com/apis/adsense/
google.com advertising http://www.google.com/apis/adwords/
upcoming.org events, seminars, meetings, gatherings http://upcoming.yahoo.com/services/api/
flickr.com photos of areas http://developer.yahoo.com/flickr/
Zillow.com property valuations http://www.zillow.com/howto/api/APIOverview.htm
zillow.com listing submission http://www.zillow.com/feeds/Feeds.htm
trulia.com property search - area trends http://developer.trulia.com/
trulia.com listing submission http://www.trulia.com/submit_listings/
alexa.com thumbnailed screenshots http://alexa.com/site/devcorner/thumbnails
mozilla.org firefox browser extensions http://mozilla.org
ebay.com post items for sale http://developer.ebay.com/
del.icio.us post lisitngs and blogs http://del.icio.us/help/api/
google.com open social http://code.google.com/apis/opensocial/
Salesforce complete CRM package https://www.salesforce.com/appexchange/…ALLAPPS
libgmailer import gmail contacts http://gmail-lite.sourceforge.net/…libgmailer/
yahoo.com import yahoo mail contacts http://developer.yahoo.com/mail/docs/html/index.html

Add to Technorati Favorites

Featured Sections