public
Created

kludge to make WordPress' Google Sitemap Generator exclude Page Links To pages linking to PDF files

  • Download Gist
gistfile1.phtml
HTML+PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?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');

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.