Does anybody understand how to customize the Wordpress canonical links to include a custom URL parameter?

I've got a Wordpress site having a page that queries another (non-Wordpress) database. I passed the URL parameter "pubID" to show individual books which is working OK.

Example: http://www.uglyducklingpresse.org/catalog/browse/item/?pubID=63

However the individual book pages aren't turning up correctly in the search engines - the ?pubID parameter is removed out.

I believe maybe the reason being all of the item pages have a similar auto-produced "canonical" URL link tag within the source Body using the "pubID" parameter removed out.

Example: link rel='canonical' href='http://www.uglyducklingpresse.org/catalog/browse/item/'

It is possible to method to possibly edit .htaccess to include a custom URL parameter to Wordpress, to ensure that the parameter isn't removed out by permalinks and also the "canonical" links?

Or possibly there's another solution ... Appreciate any ideas!

You need to have the ability to replace Wordpress's rel_canonical action function with your personal function by which (whenever your the weather is meet) you produce a canonical link appending the query string variable. The next should work, although you'll most likely have to alter the conditions to suit your needs.

remove_action('wp_head', 'rel_canonical');
add_action('wp_head', 'my_rel_canonical');

function my_rel_canonical() {
    if (is_page('item') && isset($_GET['pubID'])) {
        global $post;
        $link = get_permalink($post->ID) . '?pubID=' . absint($_GET['pubID']);
        echo "<link rel='canonical' href='$link' />\n";
    } else {
        rel_canonical();
    }
}