Notice: This forum has become difficult to maintain and will no longer be supported.
If you have a current account, please open a ticket. If you have questions about the free version of AWPCP, please post in the WordPress.org forum and our team will respond there.

Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
How to get your Sitemap working correctly
November 3, 2010
3:21 pm
awpcp
Moderator
Moderators
Forum Posts: 7530
Member Since:
August 9, 2013
sp_UserOfflineSmall Offline

The AWPCP Sitemap XML plugin is the sure-fire way to get your ads indexed by Google, but there's a small issue with Wordpress you have to tweak before it will work correctly.

First, you can get the sitemap plugin here: XML Sitemap for AWPCP

There is an issue with Wordpress that's been around since the beginning about "canonical URLs" where a bunch of URLs might really all point to the same page. Google wants to know what page is the "authority" page for ranking, and so links can be marked like this:

<a href="http://google.com" rel='canonical'>Google Homepage</a>

That rel="canonical" business means all other links that appear to go to a similar place (e.g. http://google.com/index.html, http://google.com/index.php, etc) are not the ones that will appear in Google's search results, even though all three will send you to the same "place". Only the http://google.com will be indexed. It's the "canonical" (authority) URL.

AWPCP's classifieds hang off of WP pages. WP pages are all marked with rel="canonical", meaning that any "sub pages" are ignored because they are not the authority link for that page. AWPCP uses WP pages for category browsing and showing ads, so this now blocks the ability of Google to look at your ads even if you install the sitemap XML plugin.

Well, that's wrong for AWPCP. And here's how you fix it. You MUST modify your Wordpress installation as follows (don't worry, it's EASY):

1) Using FTP, SCP or your favorite command line shell, go to your web host.
2) Find the directory <your_site>/wp-includes, where your_site is the default directory of your Wordpress installation.
3) Open the file default-filters.php.
4) Find this line

add_action( 'wp_head', 'rel_canonical' );

inside wp-includes/default-filters.php (on WP 3.0.1, it's on line 197, earlier versions say about line 185, just search for "rel_canonical" and you'll find where yours is).

5) Comment it out, like this:

//AWPCP fix for sitemap XML//add_action( 'wp_head', 'rel_canonical' );

6) Save the file.

That's it, the sitemap will index your ads correctly now. Thanks to roninv for finding this tidbit out and giving me a clue where to look on how to fix it!

EDIT: If you are running Yoast's All In One SEO Plugin, you need to ALSO uncheck "Use Canonical URLs" otherwise, it will override all your hard work here, too!

EDIT2: purplepaula makes this suggestion as well:
Are you using Google Webmaster Tools? If so make sure that the following is unchecked in Google XML Sitemaps (in Basic Options):

Add sitemap URL to the virtual robots.txt file.(The virtual robots.txt generated by WordPress is used. A real robots.txt file must NOT exist in the blog directory! )

You need to generate a robots.txt file within Webmaster Tools and add it to your server. The sitemap will then generate perfectly.

UPDATE, Feb 2, 2013:

Hat tip to holon78 who gave this helpful information:

instead of hacking the WordPress core, i recommend to put the code into the functions.php, located in your theme directory:

to deactivate the built-in canonical, try this:

add_action('init', 'remheadlink');function remheadlink() { remove_action('wp_head', 'rel_canonical');}

the yoast seo canonical tag can be removed by using this code:

add_filter( 'wpseo_canonical', '__return_false' );
Forum Timezone: America/Denver
Most Users Ever Online: 426
Currently Online:
Guest(s) 20
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Member Stats:
Guest Posters: 631
Members: 22716
Moderators: 3
Admins: 2
Forum Stats:
Groups: 1
Forums: 4
Topics: 7431
Posts: 33061
Newest Members:
miguel da mota
Moderators: awpcp: 7530, AWPCP Support: 6207, Bobbie Devereux: 3
Administrators: awpcp: 300, Steph Wells: 0