Enter your contact information.
Enter your project information.
Step 3Choose the PHP programmers you want to hire.
Compare Free PHP Quotes
WordPress categories, optimization tips and custom pages
*Attention PHP Programmers* - Add A Free Listing! Get more clients.
It’s not a SEO secret, inner links to / from strong category pages will help your site to rank higher in Google. Sad enough that Wordpress doesn’t provide a lot of functionality for these important sections on your blog site. This is the information you can read below the field “description” if you edit a category:
The description is not prominent by default, however some themes may show it.
There is no field for a second title and the description field doesn’t allow most of the HTML elements. I’m using the All in One SEO plugin because it gives me the freedom to write a custom page title or meta description (for posts or pages only). Most SEO plugins doesn’t care a lot about category pages…
First preparations
In my experience it’s the best to not index any archive page created by WordPress because they show content duplicates. The category URL could need an update first: By default you get this kind of category URL:
http://www.domain.com/archives/category/some-category-name
We need to remove the “archives” part from the URL, goto Settings->Permalinks and add some unique name for the field “Category base”.
If you use the “All in One SEO” like I do, disable the following settings:
Canonical URLs, Use noindex for Categories
Head to the plugin category, open the file (aioseop.class.php) and disable (//) row 283 to disable the creation of a meta description for all category pages:
//$description = $this->internationalize(category_description());
This function is buggy because the auto generate option will use the complete category text for a meta description.
We will create for the category pages our own META information and the canonical URLs for posts and pages are created by WordPress since version 2.9. Next you need to create some unique text for all the categories, 100 words is a great text length.
Optimizations for the “generated” category pages
We need to create some code to get the right META data in our header section. In the theme directory is a file called “functions.php”, open the file in a text editor and add this code:
function create_short_version($text, $len = 150) { $parts = explode(' ', $text); $ic = count($parts); $txt = '; for ($i = 0; $i < $ic; $i++) { $txt .= $parts[$i].' '; if (strlen($txt) >= $len) break; } $txt = trim($txt).'...'; return $txt; } function fix_meta_canonical() { global $paged; if (is_category()) { $catid = get_query_var('cat'); $catdescr = strip_tags(trim(category_description($catid))); if (strlen($catdescr) > 160) { $meta = create_short_version($catdescr); } else { $meta = $catdescr; } echo ' <link rel="canonical" href="'.get_category_link($catid).'" /> <meta name="description" content="'.$meta.'" />'; if ($paged > 1) echo ' <meta name="robots" content="noindex,follow" />'; } else { echo '; } } add_action('wp_head', 'fix_meta_canonical');
The first function “create_short_version()” is a helper which creates a short version from a text without changing the last word into something unreadable. Inside the function “fix_meta_canonical()” we create additional META information if the current page is a category. We don’t allow search engines to index other category pages than the first page.
Now we need to change our default theme file. Open the file “archive.php” (or category.php) and add the following code right below the header element and before the loop:
<?php if (is_category() && $paged < 2) { echo ' <p>'.category_description().'</p>'; } ?>
Using this code the category page will show the description as well, but only on the first page!
Optimize your most important categories
I use for most of my blog posts more than one category, for example this article is listed in the categories “PHP Scripts” and “Search engine optimization”. If you analyze your blog you will see that some category is more important or is used more often. While the steps above are okay for most the categories, it might be better to create a custom or static page for some of your categories. We did this for the category PHP Scripts.
With WordPress it’s possible to create a static page for just a single category. How does it work? Create a copy of the “archive.php” file and call it category-XX.php where XX is the category ID from the category you like to create a static page for. You can find the ID in the browser’s address bar if you edit a category. Add your custom code and the category description to this newly created file and save your work. I use the static content only for the first page and show the regular code for all underlying pages:
<?php if (is_category() && $paged < 2) { // show here your custom code/content } else { // show here the code from your archive.php file } ?>
Don’t remove any code from outside the DIV container with the ID “content”. This modifications are only for the “information part” and about the design or the layout.
Header and title improvements
For SEO reasons it’s much better to have different titles in the page title and your header element. With the following code it’s possible to tweak the page title as well:
// create here your custom titles $my_pagetitels = array( 4 => 'PHP scripts and tutorials' ); function change_cptitle() { global $my_pagetitels; $catid = get_query_var('cat'); if (array_key_exists($catid, $my_pagetitels)) { $title = $my_pagetitels[$catid]; // use a custom title } else { $title = get_the_category_by_ID($catid); // use the category name as title } return $title; } add_filter("single_cat_title", "change_cptitle");
Sure this solution is very quick and dirty, but it works
Add your custom titles within the array which is called “$my_pagetitels”. Use the category ID as array index number and enter the “page title” as value. The function will check the array for an existing value and will use the category name as alternative. With a static value for your header element you use three different values instead of only one (the category name).
Don’t forget to add your category pages the Google Sitemap, and if you blocked them in your “robots.txt” file you need to allow the access too.
That’s all, for some tweaks you need to edit several WP theme files if you add or change a category, but I’m sure it worth the time and work! Don’t forget to create some external links to your category pages! If you have any questions or suggestion, you’re welcome to post them below.Similar Posts:
- Optimizing your WordPress Blog for Google: Part 2
- Create PDF documents Online with TCPDF
- Build your own website, 10 Tips for Success!
Mon, 25 Oct 2010 07:23:58 GMT
Tags: PHP Scripts,
*Attention PHP Programmers* - Add A Free Listing! Get more clients.
PHP Scripts
Why should you cache your PHP website?
Most web servers are able to handle “normal” traffic and there are plenty of websites which doesn’t have so much traffic. So maybe you ask yourself: Why should you cache your PHP powered website? The apache web server is able to serve ma
How-to show popular posts on your WordPress blog?
Yesterday I replaced my list of current PHP articles on this blog with a list of popular articles. I’m sure it’s possible in WordPress to get those list if you count the number of comments, but actually I was looking for solution based on real
IceStar Media are a successful team of website designers, IT consultants and software programmers who have a proven track record in designing and delivering reliable business applications and websites
Stevenage, England GB
I retired 4 years ago at 32 & I'm now living in the Philippines. With 16 years experience in PHP/MySQL/JavaScript development, my passion is code. My work always exceeds expectations.
Dumaguete City, Central Visayas PH
Web Design, Implementation, and Maintenance. PHP, Javascript, JQuery, MySql
Daphne, Alabama US
Make Waves with WebGL Demo ‘Water’
Web Developer Evan Wallace has released one of the more impressive WebGL demos we’ve seen. Pr
Google Adds Google+ Info to Gmail Contacts
Google now includes Google+ profile information within contacts lists, both in Gmail and in the stan
Mozilla Eyes Mobile OS Landscape With New Boot to Gecko Project
Mozilla has announced a new experimental project called Boot to Gecko (B2G) with the aim of developi
Test Drive Firefox for Android Today
Mozilla has released Firefox for Tablets. The currently nightly build is still very rough around the
Damn the Torpedos: Mozilla Adds Flash to Firefox for Android
Adobe may be throwing in the towel, but Mozilla is going ahead with plans to add Flash support to Fi
Article Tags
PHP Programmers Articles
Live Help Chat Software
Web Design Quote
Web Design