WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Taxonomy on a custom object type

[Resolved] Taxonomy on a custom object type

  • 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/

Viewing 1 replies (of 1 total)
  • 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) . "')

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Taxonomy on a custom object type’ is closed to new replies.