Jan 21
Digg
Stumbleupon
Technorati
Delicious

WP e-Commerce SEO Tutorial

SEO Tutorial Overview

  1. Some SEO basics.
  2. Remove Wordpress headline from “products-page”.
  3. Add h1 to item/product page.
  4. Add h1 element to Category/Group pages.
  5. Title tags and meta descriptions

SEO Basics

For those of you just getting your feet wet when it comes to SEO, there are a few basic on-site optimization fundamentals that should never be overlooked, especially if you plan on driving traffic from the search engines in a competitive market. There are three main factors, the title tag, the h1 tag and the inbound anchor text to your page for successful ecommerce seo.

It is important that each page have a unique title tag and h1 tag that closely match (contain the targeted keyword phrase). The h1 tag is often and mistakenly used in the logo and is not unique to each page.  In Google’s algorithm, any content in the h1 element is more important than any other content on the page. For more on the H1 tag you can read Scott Hendison’s explanation or checkout this SEO basics article (third step).

Removing The Products Page Headline Title

WP e-Commerce uses the page template in order to display all products. For example, the products-page will contain a list of products that you choose in the setup. When you click on a category/group, that category or group will be displayed inside of the wordpress products-page. It will send a string to the URL so it may look something like: site.com/products-page/test-category

Since the wordpress products-page is always present, the title (headline) for the page will remain no matter what category or product you are viewing and will say “Products Page”. Lets get rid of the page title for the products page so we can use h1 tags that are related to our products.

The Page/Post title is featured above the content and is displayed in the page.php template with something like this (this is your general wordpress theme, not the WP e-Commerce theme):

  1.  
  2. <h1><a title="Permanent Link to <?php the_title_attribute(); ?>" rel="bookmark" href="<?php the_permalink() ?>"></a></h1>
  3.  

Lets tell wordpress to display the page title as long as the page is not the “Products Page”.

  1.  
  2. <h1><a title="Permanent Link to <?php the_title_attribute(); ?>" rel="bookmark" href="<?php the_permalink() ?>"></a></h1>
  3.  

Add H1 Element To Items Page

Not to be confused with what Wordpress calls the “Products Page”, this is the page where your individual products are for sale. For example the page would be:

site.com/products-page/example-category/another-test-product/

In products_display_functions.php on line 645 you will find the following code.

  1. $output .= "
  2. <h2 class="prodtitles">$special" . stripslashes($product[‘name’])."</h2>
  3. \n\r";

Change the h2 elements to h1 elements.

  1.      $output .= "
  2. <h1 class="prodtitles">$special" . stripslashes($product[‘name’])."</h1>
  3. \n\r";

You will need to play around with the stylesheet to get the look you want, I am not going to go to in depth into the design process here. But, In the iShop.css, look for h2.prodtitles and create another style with h1.prodtitles. If you use the same attributes, will get the same look as the h2 elements.

H1 Element On The Categories/Groups Page

You will need to edit the core WP e-Commerce files in order to get the h1 element included at the top of the categories pages. The category pages are sometimes referred to as group pages. It is important to name them with the proper keyword that you are targeting.

Open products_page.php in your favorite text editor. You will find the following code starting at line 63.

  1. if($_GET[‘product_search’] != null) {
  2.                                         echo "<strong class="cattitles">".TXT_WPSC_SEARCH_FOR." : ".stripslashes($_GET[‘product_search’])."</strong>";
  3.                                 } else {
  4.                                         $category_image = ;
  5.                                         if((get_option(’show_category_thumbnails’) == 1) &amp;&amp; ($category_data[‘image’] != null)) {
  6.                                                 $category_image = "<img class="category_image" src="".WPSC_CATEGORY_URL.$category_data[" alt="" />";
  7.                                         }
  8.                                         echo "".$category_image."<strong class="cattitles">".stripslashes($category_data['name'])."</strong>";

On line 64 replace the strong element with the h1 tag. Remember to replace the closing tag with it is well and leave the class=”cattitles” the same. Do the same thing on line 70 since it is an if/else statement.

This is how the code should look after you are done (you could just copy and paste if you like).

  1. if($_GET[‘product_search’] != null) {
  2.                                         echo "
  3. <h1 class="cattitles">".TXT_WPSC_SEARCH_FOR." : ".stripslashes($_GET[‘product_search’])."</h1>
  4. ";
  5.                                 } else {
  6.                                         $category_image = ;
  7.                                         if((get_option(’show_category_thumbnails’) == 1) &amp;&amp; ($category_data[‘image’] != null)) {
  8.                                                 $category_image = "<img class="category_image" src="".WPSC_CATEGORY_URL.$category_data[" alt="" />";
  9.                                         }
  10.                                         echo "".$category_image."
  11. <h1 class="cattitles">".stripslashes($category_data['name'])."</h1>
  12. ";

Title Tags And Meta Descriptions

The title tags and meta description hack was a little bit more involved. Most of it, actually all of it, is done outside of the WP-e-Commerce plugin. First of all, before you can test the description tag, make sure that your categories/groups have a description added to them, since this fix uses that content as the description tag for the category pages.

I built this script based on this one, I modified it to include a title tag for the products page itself. I also added the meta description capabilities.

The category pages function determines that it is indeed a category page, queries the database for the category name and puts it into the title tag. It also takes the first 150 characters of the category description and puts it into the meta description tag

The item (actual product) pages function does the same thing as the category pages function, except that it makes sure you are on the product page. It replaces the title tag with the product name and blog info (you need to edit script to put your blog info in). It also includes the first 150 characters of the first description in the meta description tag.

The title tag and meta description for the main products page(products-page) is added manually when you install the script. Simply, replace, “My Products Page Title” with the appropriate title tag.

I normally use a plugin to add the meta description tag, but that plugin conflicted with WP e-Commerce. So I am using SEO Title Tag and wrote the next part of the script to add the description tag. Basically, it simply adds the description tag to every page that is not on the products page by adding the first 150 characters of the post.

This goes into the main Wordpress header template where your normal title tag would go.

  1. ".$productname." | site name
  2. ";
  3. }
  4. ///////// Function to Find Category Name /////////////
  5. function oGetCategoryName( $nicename ){
  6. global $table_prefix;
  7. $query = "SELECT name, description
  8. FROM ".$table_prefix."product_categories
  9. WHERE `nice-name` = ‘".$nicename."’";
  10. $result = mysql_query( $query );
  11. $row = mysql_fetch_array( $result );
  12. $name = $row['name'];
  13. $description = $row['description'];
  14. //Category Title Tag and Description — Change the name below to reflect your site
  15. return "".$name." | site name
  16. ";
  17. }
  18. //this if state will determine if we are on the products page, the category page or the actual products page (item page) and call the appropriate function
  19. if(get_the_title() == ‘Products Page’ ){
  20. $pparts = explode(’/', trim($_SERVER['REQUEST_URI'],’/') );
  21. if( $pparts[2] != ” ){
  22. echo oGetProductName( $pparts[2] );
  23. }
  24. else if( $pparts[1] != ” ){
  25. echo oGetCategoryName( $pparts[1] );
  26. }
  27. //if we make it this far in the if statement, than we know that we are on the main products-page listing what you have for sale, manually edit this to reflect what you want the title tag to be and what description you want to use.
  28. else {
  29. ?> your title tag for home
  30.  
  31. <?php if (function_exists(’seo_title_tag’)) { seo_title_tag(); } else { bloginfo(’name’); wp_title();}
  32. ?>

Alright, you should be well on the way to a nicely optimized WP e-Commerce site.

Author: Jason

44 Comments

siambookmark
January 21, 2009

thank you good

Jason
January 22, 2009

I am glad you found it useful.

Tobias
February 7, 2009

hey. i think the beginning of the title tag code is missing, isn´t it?

Tobias
February 7, 2009

also, the two pieces of code for “Removing The Products Page Headline Title” are identical

Olivier from Breast Pumps from Avent
February 10, 2009

Replacing the h2 tag with a h1 is indeed a cunning idea (as would the Blackadder say (this is from a British comedy series)) But indeed, we all should look into our templates to see whether there are these kind of little optimisations can we could profit from.
Thanks for the good advice.

butik online
February 15, 2009

great tutorial. i used it. thank u

martial arts equipment
February 21, 2009

Great,Thank you!
For keywords and description meta attributes,I like to use all-in-one-seo plugin,That’s great!

CharlieO
February 26, 2009

Brilliant little summary - thank you for sharing. I’m using AllInOneSEO plugin for meta and page titles too with no problems spotted yet.

The two snippets of code above for removing Products Page Headline Title are the same, as Tobias points out - I’d love to see that corrected if you have a spare minute. I don’t know how to write an if statement (?) to determine if it is the products page or not so might just strip all that code out for the time being!

Jason
February 27, 2009

Sorry for the delay…I have updated both errors.

Tobias
February 28, 2009

hey jason. thanks for the update, but i´m still getting an unexpected t_string error when Removing The Products Page Headline Title your way

Tobias
February 28, 2009

same for the meta-tag-fix. using wp 2.7 and wp ecommerce 3.6.8 rc 3

Jason
March 2, 2009

@Tobias, I will post my complete header.php file for you to download later. I am not sure why you are getting the error and I will take a look at it.

Peter
March 3, 2009

Tobias - have you perhaps renamed your products page?

jer
March 7, 2009

you should offer a paid service to do this. i could use the help. having nothing but problems with 2.7.1 :0(

zorito
March 26, 2009

beautiful blog merciiii

James
March 31, 2009

I am using all in one seo and wpremix for my blog them and I cannot change my header.php title tag. Is there any way this company is going to produce a plugin with built in seo features???

nick from ecommerce development
May 4, 2009

SEO can be a daunting task to begin with, but adding SEO to an ecommerce site is even more difficult. I think you offer some great tips that everyone should take advantage of. Thanks for the write up!

nick from Advanced SEO
May 4, 2009

I have been having a ton of trouble getting my online store that uses wp e-commerce indexed properly. it gets very few visitors a day. your post makes alot of good points. im gonna implement just about everything you say here. ill let you know hoe it goes.

nick from ecommerce development
May 18, 2009

You offer great tips. H1 tags are very important, what i think people forget is the fact that it should only be used one time per page. Use H2 or H3 tags if you need to, but using too many H1 tags is like bolding your entire paragraph… it looses its emphasis.

Ben
May 20, 2009

In Fact, I am getting the t_string error as well. Would be great otherwise to have this code running well in my wp header.php file. I tried several times to paste this into my original header from wp default theme, 2.7.1 WP. Any editing to this php code please? I am otherwise all right to do such changes but in these regards it’s not working. With compliment and anticipation. Thank you very much!!!

techbreaking
May 21, 2009

Cool tutorial. help me very much.

Adam from st louis brazilian jiu jitsu
June 6, 2009

Hi,

I’m just new in this SEO thing. what is WP-e? I just bookmarked your website. hope to get an answer. thanks!

well put together and very useful. Since fixing numerous sites using your guide we were able to see a jump in rankings for multiple websites. Duplicate descriptions and titles is a major issue for seo. Well done

Nikkatsu
June 7, 2009

Having trouble with both my sites using this.

Unexpected T string.

Any help?
Please email me.

nikkatsu
June 7, 2009

Can’t get this to work.

Unexpected T string.

I have 2 sites and get same error, can anyone help me?

Justin
June 15, 2009

Getting this error

Parse error: syntax error, unexpected $end in /home/cultcine/public_html/wp-content/themes/Black_Wood_0_1_1923/header.php on line 194

Line 194 has no code, so what’s the problem??

My products page is named (products-page) for some reason
and the code above doesn’t get rid of it in URL.

Can you please email me and help me out on this.?

Cem Uğur
June 23, 2009

Hi, i am trying to add all products and related pages with products to sitemap.
i m using google-sitemap-generator plugin and wp-e-commerce plugin.
i can add manually all products to sitemap but i want to do it with codes.

do you have any idea?

complexity
July 4, 2009

Missing a } at the end.

I haven’t figured out how to get descriptions working on a product page yet though.

jogja
July 7, 2009

thanks, it is usefull tutorial…
Thank You

amy from toxic mold removal
July 12, 2009

Replacing the h2 tag with h1 sounds interesting. I will have to try it on one site and see how it effects search results for site. Some great ideas i am going to try one at a time on different sites.

Matthew
July 16, 2009

Hi, I am trying to fix a silly problem in e-commerce where the meta tag for description says “[productspage]”

You didn’t mention this so I was wondering if following your changes will add a good description to each product.

Also when I try and copy/paste your code I get a number sign for each line.

Could we get it in a plain text file for easy copying.

Great article, thanks for your help.

Michelle
July 27, 2009

Hi,

Is there a WP e-commerce theme that you would recommend that’s great for SEO and all ready has some of the info above in it?

Jason
July 30, 2009

@Michelle, I do not. You will have to manually change the CSS files and HTML to make the themes SEO’d

Quality Banner Stands
August 25, 2009

Thanks for accompanying your code as well… it was easier to follow than other posts

mario
September 1, 2009

syntax error also here….
does anybody have the correct version of scripts above?
I wonder why Jason have been so kind to spend his precious time in this post with so many interesting arguments for then leave it unusable for the people. (expecially for who uses latest releases where several files and paths have been changed)
It sounds to me so odd……

Jason
September 2, 2009

Mario…my fascination with wp-ecommerce is over. I have now switched all of my ecommerce to Magento. However, I do plan an addon soon to customize your seo stuff for wp ecommerce.

Juliawan
September 13, 2009

maybe I can use that

Gautam from Oes Tsetnoc
September 18, 2009

This is one of the best tutorial on optimizing the WP e-commerce!

Thanks!

Bryan
October 12, 2009

It really surprised me in that thread that Dan from WPecommerce asked what a SERP was. If a WP programmer had even a little bit of SEO knowledge, we wouldn’t have to be modifying the php code. It would be built in.

I can’t even get any of the Sitemaps plugins to work on my site. Apparently product pages are built at runtime, which conflicts with the normal WP standard that makes nice looking sitemap pages.

Has anyone had success with a Sitemap and WPecommerce, or have a mod that makes them work. My sitemap indexes 5 pages of my whole site: Home, Checkout, About, Transaction Results, Your Account.

Thanks for the great article!

Jason
October 16, 2009

@Bryan,

Ye….what are SERPS? Just kidding. That is actually kinda scary. I do not know of anything that would work for the sitemaps.

I would like to put together a group of developers to come up with a completely viable ecommerce option for wordpress.

Andrew Weisman
October 25, 2009

Hi. Your entry was very helpful, to those who are working hard in increasing traffic, and dealing with seo. This could really help those beginners. I enjoyed reading it. This would be of help to me.

Anyway, do you know the next Google PR update?

Thanks. Nice website you got here..

Lisa
December 28, 2009

Hi there

Thanks for providing these tips!

I have looked and looked and the ‘Removing The Products Page Headline Title’ code still seems to look the same in the before and after?

Also, does Magento work with WordPress or is it a stand alone e-commerce where you build the website and the shopping cart in one?

Pop Up Banner Stands
January 10, 2010

remember folks not to use more than 1 h1 tag per page - i quite like “all in one seo pack” - allows you to manually enter seo info per page

Jonny from registry winner review
January 11, 2010

It is cool, i have never mentioned css before, thanks for your guide.

Comments RSS TrackBack Identifier URI

Leave a comment

CommentLuv Enabled

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.