How to Set Meta Tags on sh404 Using PHP

If you want to enhance your Joomla website’s SEO, the first thing that you will need to work with is your meta tags, particularly the description meta tag. If you’re using sh404, you can set the meta description for each page using the sh404 interface. However, this method is not convenient for the following couple of reasons:

  1. If you have duplicate links you will need to change the meta description for each and every link. (sh404 works on a link basis, and not on a page basis)
  2. It will take a long, long time trying to set the description meta tag if you have a VirtueMart store with thousands of products.

So, what can you do to overcome this problem? Well, the solution is simple, you just modify the PHP code in the file shPageRewrite.php, which is located under /your_joomla_website_folder/components/com_sh404sef folder.

Let’s assume that your VirtueMart store has thousands of products, and only a few have a meaningful description. The product description will be automatically used by Joomla for meta description for those products that already have a description, but what about the other products? Obviously, they will not have a meta description, which will adversely affect your SEO standings. Now, an excellent way to handle this issue is by automatically creating a proper meta description for each and every product to do the following:

  • Get the product ID (you can easily get it from the Joomla get parameters).
  • Get the category ID.
  • Create a function that will get the product name and another one that will get the category name.
  • Get the top 10 products falling under this product’s category.
  • Create a meta description for the product that sounds something like “Product A belongs to Category C. Products similar to Product A include here goes a list of the top 10 products falling under Category C.

The above code should be placed in the file shPageRewrite.php, just after the following code:

      if (!is_null($shCustomDescriptionTag)) {
        $t = htmlspecialchars( shCleanUpDesc($shCustomDescriptionTag), ENT_COMPAT, 'UTF-8');
        $t = preg_replace( '#\$([0-9]*)#', '\\\$${1}', $t);

The string resulting from your above code should be placed in the $t variable.

As you can see, this is pretty advanced stuff, and you need to be a programmer in order to do this. Now, if you’re not a programmer and you need help implementing the above, then you can rely on us. We have worked on many, many Joomla websites and we are confident we can help you with yours. Just contact us and we’ll take it form there. Don’t worry, our fees are very fair!

No comments yet.

Leave a comment