Posts tagged ‘theme’

Conditional page/post navigation links in WordPress (redux)

Monday, November 19th, 2007

After more helpful input, I’ve decided to update my original solution.

Instead of overriding four WordPress functions and adding two new ones in my functions.php file, I have slimmed it down to just one:

/**
 * If more than one page exists, return TRUE.
 */
function show_posts_nav() {
	global $wp_query;
	return ($wp_query->max_num_pages > 1) ? TRUE : FALSE;
}

This function will tell me if there is more than one page…and if there is, I will show the posts navigation (next_posts_link and previous_posts_link). I updated my WordPress (index.php, archives.php and search.php) files with:

<?php if (show_posts_nav()) : ?>
<div class='navigation'>
	<span class='older'><?php next_posts_link('&laquo; Older Entries'); ?></span>
	<span class='newer'><?php previous_posts_link('Newer Entries &raquo;'); ?></span>
</div>
<?php endif; ?>

As for the single post next/previous links, I decided to remove the check because I’ll always have more than one entry.

Much cleaner and less code ;)

Conditional page/post navigation links in WordPress

Sunday, November 18th, 2007
Update: This post has been replaced with an updated version.

While creating a new theme for this site, I added some CSS styling around the page/post navigation links.

For example, in my index.php page, I have the following HTML/WordPress code:

<div class='navigation'>
  <span class='older'><?php next_posts_link('&laquo; Older Entries') ?></span>
  <span class='newer'><?php previous_posts_link('Newer Entries &raquo;') ?></span>
</div>

And the following CSS code:

.navigation {font-size:.7em; background:#353535; height:16px; margin:0 -16px 8px -16px; padding:8px 6px 0px;}
.navigation span {margin-top:-4px;}
.navigation .older {float:left;}
.navigation .newer {float:right;}

Everything looked great, until I brought up a page that did not have a previous or next link. The styled navigation div was still there, but there was nothing in it. So, I set out to conditionally display the navigation div if either a previous or next link existed.

Read the rest of this entry »

New site design

Wednesday, November 14th, 2007

I finally got around to updating the theme for this site. It was quite an adventure learning about WordPress Themes and its API. The more I use WordPress, the more I like it!

Thanks to my brother-in-law, Max, for helpful tips on my new logo and also to Michael Heilemann for his default WordPress theme, which I used as a reference.

As time allows, I’ll be adding content to the about, resume, projects and contact pages.

If you have any comments or criticism ( hopefully constructive ;) ) on the new site design, I’d like to hear them…

Another attempt

Saturday, September 1st, 2007

I’ve decided to take another shot at updating my site and starting a blog…

I’ve chosen WordPress and while I’m trying to create/find a design, I’m just going to use this “default” theme.

This site will mostly be used as a place to store code I’m writing/testing, but I’ll also be adding various anecdotes about work, family, technology, etc…