Some simple useful Wordpress code bits
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'); ?>

No Comments Leave a comment
No comments yet.
TrackBack URL