Search code examples
javascriptgdatablogger

retrieve list of all labels in blogger


Is there a way to use gdata api to retrieve the list of all labels in a blogger?

I need to create a menu based on that list, but cannot simply list all posts and get it, because it is a busy blog and has more than 2000 posts.


Solution

  • The way I found was using the Blogger's own gadget called Labels. It prints the list of labels and their usage count within some unordered lists(ul) and links(a). You can pull the labels from that after they are loaded using javascript as follows:

    $(".list-label-widget-content a").each(function (i, el) {
        var labelText = $(el).text();
        // do what you want with the labels
    });
    

    in the end, remove the Labels div element (<div class='widget Label' id='Label1'>)