I came across an interesting problem. When you create a WordPress site and your blog page is you home page, there is no editable page in your administration dashboard. Normally, your title tag in WordPress looks like this:
<title>
<?php wp_title('«', true, 'right'); ?>
<?php bloginfo('name'); ?>
</title>
/*
* This Generates:
* <title>
* Your Blog Name
* </title>
*
* when you are at you home page. And:
*
* <title>
* Your Post Title « Your Blog Name
* </title>
*
* when you are on a post page
*/
The problem is that wp_title() doesn’t have any title to return because your blog page isn’t an editable page in your dashboard. Here is a small hack to get it to work. You will need to make sure to fill out your tagline in Administration->Settings->General->Tagline. This input will act as your title.
<title>
<?php if (is_home()) :
bloginfo('description');
echo " « ";
else :
wp_title('«', true, 'right');
endif;?>
<?php bloginfo('name'); ?>
</title>
/*
* This Generates:
* <title>
* Your Tagline Description « Your Blog Name
* </title>
*
* when you are at you home page. And:
*
* <title>
* Your Post Title « Your Blog Name
* </title>
*
* when you are on a post page
*/
When I first started out using WordPress, I had only one page template. Inside my index.php file under my theme folder, I would run case-statements that would check the page id, and then I would insert my desired html inside each case. Needless to say, this is NOT how you should be developing on WordPress.
After watching a screen cast by Chris Coyier, I discovered that you could create page templates for your different page structures. Let’s say you have a splash home page, a blog, and a photo archive. All three of these pages would probably need to have their own design structure. To accomplish this, you simply copy one of your current page layouts, say…index.php. You create a new file and name it something related to it’s theme, like splash-page.php. You then paste your code and structure it the way you need your spash page to be. Make sure you add this snippet of code to your header.
<?php
/*
* Template Name: Splash Page
*
*/
?>
This is needed so your new template will show up from the drop down menu for your template selection. Click on the picture below to see where to change your pages template.
Here is the link to the technical specs about creating your own WordPress theme.
Here is how you add a category slug to your url in wordpress. Under settings->permalinks, type this under custom structure:
/%category%/%year%/%monthnum%/%postname%/
The more structure and clarity your url has, the easier it is for both search engines and humans to understand it. Search engines put a lot of weight on your url. Take for example these two addresses.
http://webplantmedia.com/?id=6
http://webplantmedia.com/business/2010/03/how-to-make-money/
One url is significantly clearer than the other. And search engines like this kind of clarity.
Adding on, it helps to add a category slug to your url. It’s the difference between having a folder dumped with a bunch of different files and categorizing all those files into relevant folders. One is intuitively easier to navigate through than the other. And again, search engines like this kind of clarity and structure.
Here is a list of other common structure tags
%year%
%monthnum%
%day%
%hour%
%minute%
%second%
%postname%
%post_id%
%category%
%author%
Originally, I had my WordPress settings set for my homepage to be static. I ended up changing my home page to be set to read my latest post and no longer be a static page. The problem that came up is wp_list_pages() returns links to your WordPress pages, but doesn’t return a link to your blog page with your recent posts. So, here is a small hack on how I got my homepage menu button to display.
<div class="menu_buttons">
<li <? if(is_home()) echo 'class="current_page_item"'; ?>>
<a href="<?php echo get_option('home'); ?>/">Home</a>
</li>
<?php wp_list_pages(array('title_li' => '')); ?>
</div>
I’m not sure if it’s possible to declare a source path in the image tag by the root directory. The following code will not reference the desired image.
<img src="<?php echo TEMPLATEPATH; ?>/images/logo.png" />
WordPress seems to call all their files starting from the http:// protocol. Normally, I would say it’s good practice to call images and files relative from you current directory. But in this case, I can’t seem to find a way to reference images from my sub-directories without hard-coding in the path. Unless someone knows a better way, I will continue using the hack below.
<img src="<?php bloginfo('template_directory'); ?>/images/logo.png" />