WordPress.org

Support

Support » Plugins and Hacks » Google News Sitemap Generator » [Resolved] Need addition of Genres taxonomy

[Resolved] Need addition of Genres taxonomy

  • I registered a genres custom taxonomy in functions.php but I don’t know how to tweak Google News Sitemap Generator to output the information into my sitemap.

    I added this to my functions.php

    function create_my_taxonomies() {
    register_taxonomy('genres', 'post', array(
    'hierarchical' => false, 'label' => 'Genres',
    'query_var' => true, 'rewrite' => true));
    }
    add_action('init', 'create_my_taxonomies', 0);

    And I don’t know how to pull the genres into the XML output. I tried the code below but it didn’t work.

    $xmlOutput.= "\t\t\t\t<news:genres>";
    		$xmlOutput.= wp_get_object_terms($post->ID, 'genres');
    		$xmlOutput.= "</news:genres>\n";

    What I get in the output is:
    <news:genres>Array</news:genres>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Okay, tried modifying the code, still doesn’t quite work. Here’s what I come up with.

    For functions.php

    //START Custom Taxonomy for Genres
    add_action( 'init', 'create_my_genres' );
    function create_my_genres() {
     $labels = array(
        'name' => _x( 'Genres', 'taxonomy general name' ),
        'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Genres' ),
        'all_items' => __( 'All Genres' ),
        'parent_item' => __( 'Parent Genre' ),
        'parent_item_colon' => __( 'Parent Genre:' ),
        'edit_item' => __( 'Edit Genre' ),
        'update_item' => __( 'Update Genre' ),
        'add_new_item' => __( 'Add New Genre' ),
        'new_item_name' => __( 'New Genre' ),
      ); 	
    
    register_taxonomy('genre', 'post', array(
      'hierarchical' => true,
      'labels' => $labels
    ));
    }
    //END Custom Taxonomy for Genres

    And for the plugin file:

    //START GENRES
    	        $xmlOutput.= "\t\t\t<news:genres>";
    		$xmlOutput.= strip_tags( get_the_term_list( $post->ID, 'genre', '', '', '' ) );
    		$xmlOutput.= "</news:genres>\n";
    		//END GENRES

    It now pulls Genres and outputs without the hyperlinking. The problem is that it isn’t post specific and it just pulls the genre for the last published post, tagging every single post with that genre in the sitemap.

    Still stumped. I tried contacting the plugin author with no response which is why I tried taking this on myself.

    Okay, found a better plugin Google XML News Sitemap plugin. Resolved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Need addition of Genres taxonomy’ is closed to new replies.
Skip to toolbar