Skip to content

Instantly share code, notes, and snippets.

@webaware
Created August 16, 2012 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webaware/3368517 to your computer and use it in GitHub Desktop.
Save webaware/3368517 to your computer and use it in GitHub Desktop.
kludge to make WordPress' Google Sitemap Generator exclude Page Links To pages linking to PDF files
<?php
function filterSitemapOptions($opts) {
global $wpdb;
// tell it to exclude any pages that are just page-links-to links to PDF files
$exclude = $wpdb->get_col("select post_id from $wpdb->postmeta where meta_key = '_links_to' and meta_value like '%.pdf'");
if (!empty($exclude)) {
$opts['sm_b_exclude'] = array_merge($opts['sm_b_exclude'], $exclude);
}
return $opts;
}
add_filter('option_sm_options', 'filterSitemapOptions');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment