WordPress.org

Ready to get started?Download WordPress

Forums

Google XML Sitemaps
[resolved] Taxonomy on a custom object type (2 posts)

  1. Darsch
    Member
    Posted 1 year ago #

    Hello, I have a custom taxonomy registered on a custom object. Initially it was not showed in the plugin administration panel, but I changed the function "GetCustomTaxonomies" in this way:

    From: $taxonomies = get_object_taxonomies('post');

    To: $taxonomies = get_object_taxonomies(get_post_types(array("public"=>1)));

    This way the custom taxonomy on any custom type is correctly detected.

    The problem is that, even if the "Include taxonomy pages for xxx" option is now showing in the admin page, and the debug page is correctly showing my custom taxonomy in the "sm_in_tax" array, the urls are still not included in the sitemap.

    Am I missing something? Can someone help me?

    Thanks, Darsch.

    http://wordpress.org/extend/plugins/google-sitemap-generator/

  2. Darsch
    Member
    Posted 1 year ago #

    Ok I found.

    In sitemap-core.php the "//Add custom taxonomy pages" section should take into account also custom types other than "post".

    I made some changes, maybe useful for the developer:

    Inside the //Add custom taxonomy pages section

    FIND:

    $taxList = array();
    
    			foreach ($enabledTaxonomies as $taxName) {
    				$taxonomy = get_taxonomy($taxName);
    				if($taxonomy) $taxList[] = $wpdb->escape($taxonomy->name);
    			}

    REPLACE WITH:

    $taxList = array();
    			$typeList = array();
    
    			foreach ($enabledTaxonomies as $taxName) {
    				$taxonomy = get_taxonomy($taxName);
    				if($taxonomy) {
    						$taxList[] = $wpdb->escape($taxonomy->name);
    						$types = $taxonomy->object_type;
    						foreach ($types as $type) {
    							$typeEsc = $wpdb->escape($type);
    							if (!in_array($typeEsc, $typeList)) $typeList[] = $typeEsc;
    						}
    				}
    			}

    FIND:
    AND p.post_type = 'post'

    REPLACE WITH:
    AND p.post_type IN ('" . implode("','",$typeList) . "')

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic