WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Filter using 'wpseo_typecount_where' in 'build_root_map' (2 posts)

  1. Jeff Pye Brook
    Member
    Posted 1 year ago #

    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?

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. Jeff Pye Brook
    Member
    Posted 1 year ago #

    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 http://www.sparkle-gear.com.

    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 );

    with

    $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 );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic