WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Random Category Icons in Sidebar

[Resolved] Random Category Icons in Sidebar

  • Hello,

    I was wondering if there was a way to show random category icons in the sidebar. I am using a PHP Widget Box to show the following random categories currently. Is there a way to add the category icons to this code?

    <?php
    // display 10 random categories
    $cats ='';
    $categories=get_categories();
    $rand_keys = array_rand($categories, 10);
    foreach ($rand_keys as $key) {
    $cats .= $categories[$key]->term_id .',';
    }
    wp_list_categories('title_li=&hierarchical=true&hide_empty=0&show_count=1&include='.$cats);
    ?>

    Thanks,
    Steve

Viewing 2 replies - 1 through 2 (of 2 total)
  • Never Mind. I figured it out.

    If anyone is using the Category Icons Plugin and wants to call the code into a sidebar widget and have it pull random list of 10, use the following code:

    <?php
    $cats ='';
    $categories=get_categories();
    $rand_keys = array_rand($categories, 10);
    foreach ($rand_keys as $key) {
    $cats .= $categories[$key]->term_id .',';
    }
    put_cat_icons(wp_list_categories('title_li=&echo=0&hierarchical=1&hide_empty=0&orderby=name&show_count=1&include='.$cats));
    ?>

    Of course you can change the 10 in the code about to show any number you wish.

    Plugin Author submarine

    @submarine

    Hi, thanks for sharing !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Random Category Icons in Sidebar’ is closed to new replies.