Optimize your WordPress theme for Search Engines – Part 1

WordPress Recently I was updating my themes, and I got to thinking about SEO a little and about how to apply it to a theme to help out the blog author. One of the biggest complaints with WordPress 2.7 is the comment pagination and duplicate content. Google detects the comment pages as duplicate even when the comments are different. The easiest thing is to append comment page N to the title and meta description. To do this you need to edit the header.php of your theme and add this between the <title> </title> tags.

<title><?php if ( is_single() ) { wp_title(''); if ( $cpage < 1 ) {}
else { echo (' - comment page '); echo ($cpage);} ?> | <?php } ?><?php bloginfo('name'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; if ($paged > 1) { echo " - Page $paged"; } ?></title>

I’ll explain the code now. The first if finds if it is a single post or page then it prints the title of the post or page first then the second if finds if its a comment page then it appends – comment page 1 and so on to the title. Next is the | which serves as a separator for the title of the post and title of the blog. Next the name of the blog is printed then next comes some code to find if the current page is a older posts page and if it is then it prints Page 2 and so on. This is also to eliminate duplicate title tags. Tomorrow I’ll go over how to pull an excerpt and make it the meta description which is also helpful for your search rank. You can follow the whole series here.

About Jeremy Clark

Small town IT worker with interests in all things technological and technical. Biggest interests are in web development especially the WordPress publishing platform and the community supporting it. Currently developing and maintain the free WordPress theme Techozoic. I'm also always available for hire.
This entry was posted in wordpress and tagged , , , . Bookmark the permalink.

2 Responses to "Optimize your WordPress theme for Search Engines – Part 1"

Leave a reply

Comments will be sent to the moderation queue.