bee-digital design logo
Frontpage image

Some simple useful Wordpress code bits

18th November 2008 - by Kristian

I’m writing this as a sort of reminder to myself. These are some handy Wordpress bits to solve things I need as I develop this site how I want it.

A Google friendly title with a custom name for specific pages

Write the title as “Home” unless you are on a post, category or another page. It will also make the title more Google friendly, as it shows “Pagename – Sitename”. Put this inside your title tag. You have to adjust this if you are not using the default permanent links or make a new page type that’s not covered by page_id, p or cat.

<?php wp_title('','title',''); ?><?php if ($page_id == '' && $p == '' && $cat == '') { echo "Home";} ?> - <?php bloginfo('name'); ?>
A category list like my worklog archive

You can see how it looks in my left sidebar. I just wanted this simple list.

A short explanation:

  • title_li is empty because I don’t want a title in front of the list
  • hide_emtpy is 0 because I don’t want to hide empty categories
  • show_count is 1 because I want to show how many posts are in each category
  • style is none because I wanted clean links. If you set it to list you get an unordered list.
<?php wp_list_categories ('title_li=&hide_empty=0&show_count=1&style=none'); ?>
Bookmark and Share

No Comments Leave a comment

No comments yet.

TrackBack URL

Leave a comment

Welcome to my worklog and portfolio

My name is Kristian B. Hollund and this is my worklog. A place to put solutions, problems and thoughts on a lot of webdesign, photography, and other topics I encounter at work or in my sparetime.

  • Twitter updates

Copyright © 2008 - bee-digital design