Lee Willis

Custom Taxonomies In WordPress Plugins

| 9 Comments

Taxonomy Support

I wrote recently about building a brand directory using a fantastic feature of WordPress called “Taxonomies”. Now that that feature is live I’ve realised that a number of my favourite WordPress plugins simply don’t support taxonomies.

Among the casualities were Google XML Sitemaps, and the otherwise excellent Headspace2.

Now, the beauty of open source is that when you get an itch like this, you can go and scratch it. So, I whipped out my coding gloves and set to work.

The results are below:

Google XML Sitemaps

The patch below will ensure that the pages for all of your taxonomy terms are listed in your sitemap – helping Google find the pages quicker.

http://www.leewillis.co.uk/patches/google-sitemap-generator/include_taxonomies.txt

HeadSpace2

The patch below lets you add %%term_description%% so you can populate your META tags properly on your term pages – great for us and our product directory.

http://www.leewillis.co.uk/patches/taxonomy_support_for_headspace/patch_v2.diff

Both of these have been submitted to the plugin authors – so hopefully they’ll get included by default in a future release. If you find them useful – please add to the threads here:

Google XML Sitemaps

Headspace2

9 Comments

  1. There’s an updated version of the patch for Google XML Sitemaps v3.1.5 here:

    http://www.leewillis.co.uk/patches/google-sitemap-generator/include_taxonomies_v3.1.5.txt

  2. And another update against version 3.1.6 here. This version also calculates a modification date based on the most recent article tagged with a term – which should help Google pick up changes to your term archive pages:

    http://www.leewillis.co.uk/patches/google-sitemap-generator/include_taxonomies_v3.1.6.txt

  3. wow. the Goog XML Siteap patch is much needed – great work.

    now that i found it, what do i do with it / where do i put it / how ..?

    • Hi, You need to apply the patch to your current plugin using the UNIX “patch” utility. Quick example below (This assumes that you’ve got shell access to your webhost):

      Download the patch (Make sure to grab the right version for the version of the plugin you’ve got installed), and save it in the plugin directory (wp-content/plugins/google-sitemap-generator) as patch.txt. Then run the following commands:

      $ cd wp-content/plugins/
      $ patch -p1 < patch.txt

      If you don't have any joy with that, then let me know, and I'll try and put some ready-patched versions up – but that won't be until tonight I'm afraid …

  4. Since I’ve had a couple of requests from people who aren’t really into patching – I’ve put copies of the ready patched files here:

    http://www.leewillis.co.uk/patches/google-sitemap-generator/3.1.6/sitemap-core.php
    http://www.leewillis.co.uk/patches/google-sitemap-generator/3.1.6/sitemap-ui.php

    Simply put these in wp-content/plugins/google-sitemap-generator in place of the current versions and you’ll get the new functionality.

    Note: These are for version 3.1.6 of the plugin only.

  5. wow. worked like a dream Lee – thank you.

  6. @Lee,
    google sitemap generator 3.1.7 is out..so will your patches work with it ?

  7. @eddai – Actually version 3.1.7 should already support custom taxonomies – Arne (The developer) accepted my patches – I just hadn’t got around to updating this post just yet. Hope that helps.

  8. Actually – there’s a really small bug in 3.1.7 that causes the modification dates to not show up properly. Fortunately the fix is simple – just add the following to the end of the $lastMods query on line 2198:

    GROUP BY r.term_taxonomy_id

    So the whole query reads:

    SELECT
    r.term_taxonomy_id AS term_id,
    UNIX_TIMESTAMP(MAX(post_date_gmt)) as mod_date
    FROM
    {$wpdb->posts} p , {$wpdb->term_relationships} r
    WHERE
    p.ID = r.object_id
    AND p.post_status = ‘publish’
    AND p.post_type = ‘post’
    AND p.post_password = ”
    AND r.term_taxonomy_id IN ( “. implode(‘,’,$termIDs) .”)
    GROUP BY r.term_taxonomy_id

Leave a Reply

Required fields are marked *.