Support » Plugin: Yoast SEO » Filter using 'wpseo_typecount_where' in 'build_root_map'

  • I needed to add a filter to avoid including wp e-commerce child products in the sitemap and noticed that when the root map is made it doesn’t apply the wpseo_typecount_where filter that is applied when the ‘build_post_type_map‘ function creates the map for the specific post type.

    It appears that this causes the root map to have the incorrect number of child maps?

Viewing 1 replies (of 1 total)
  • I made the change and the fix seems to work. In build_root_map() I replaced the sql statement formation with the code from the function that builds the individual sitemaps. Test on my dev system, and on a production site

    In function build_root_map replace

    $query = $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = '%s' AND post_status IN ('publish','inherit')", $post_type );
    $count = $wpdb->get_var( $query );


    $where_filter = '';
    $where_filter = apply_filters( 'wpseo_typecount_where', $where_filter, $post_type );
    $query = $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts {$join_filter} WHERE post_status IN ('publish','inherit') AND post_password = '' AND post_type = %s " . $where_filter, $post_type );
Viewing 1 replies (of 1 total)
  • The topic ‘Filter using 'wpseo_typecount_where' in 'build_root_map'’ is closed to new replies.