WordPress.org

Ready to get started?Download WordPress

Forums

Category Icons
[resolved] Widget stopped displaying icons (24 posts)

  1. Echtzeit
    Member
    Posted 1 year ago #

    Hello there,

    everything with this wonderful plugin worked literally for years, but yesterday I clicked on "Position of the category icons in the sidebar" on "Right" and then all the icons in the widget disappeared.

    Even after changing it back to left and trying pretty much everything I could think of, the icons just won't come back. Any ideas on how to show them again?

    http://wordpress.org/extend/plugins/category-icons/

  2. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    What is the value in your database, in the wp_options table, of the option "igcaticons_before_name" ? If it is set to false, what happens if you set it to 0, instead ?

  3. Echtzeit
    Member
    Posted 1 year ago #

    It's set to true.

  4. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    If you set it to 1, instead, it is working ?

  5. Echtzeit
    Member
    Posted 1 year ago #

    Changed it to 1, deleted the widget in the sidebar and added it again. Nothing has changed.

  6. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    If you go in the icons panel, are you able to view the icons ?

  7. Echtzeit
    Member
    Posted 1 year ago #

    Yeah. Everything concerning the plugins works as intended (as far as I'm using it).

  8. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    This is uber weird.
    Did you try this :

    • test the widget in another theme ?
    • deactivate, delete it and reinstall the plugin ?
  9. Echtzeit
    Member
    Posted 1 year ago #

    I have it installed on two other blogs and it works just fine. It did work here too for more than a year, until I changed that setting.

    Deactivating and reinstalling did nothing.

    I'm trying to replicate what the widget does in a different widget (that can handle php), but find it rather hard, cause I'm not a programmer.

  10. submarine
    Member
    Plugin Author

    Posted 1 year ago #

  11. Echtzeit
    Member
    Posted 1 year ago #

    Oddly enough, this actually works! I can't thank you enough.

    Only ONE tiny thing missing, though. I need the categories to display hierarchical and I've tried tampering with the code, but couldn't get it to work. Could you tell me how to do this?

    After that I'm most definitely gonna buy you a coffee ;)

  12. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I think this should do the job :

    function bm_caticons_listing() {
    	$lis = array();
    	// Get the categories
        foreach(get_categories() as $category) {
           $link = '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
           $lis[$category->cat_ID] = '<li>'.get_cat_icon("echo=false&cat=".$category->cat_ID).' '.$category->description.' '.$link.'</li>';
        }
    
        // order the categories
        $r = array('orderby' => 'name', 'order' => 'ASC', 'hierarchical' => true, 'echo' => 0, 'hide_empty' => 0);
        $depth = 0 ;
        $order = bm_caticons_walk_tree(get_categories( $r ), $depth, $r );
        $order = explode(',',$order);
    
        $listing_code = '<ul>';
        foreach ($order as $index) {
    	    $listing_code .= $lis[$index];
        }
        $listing_code .= '</ul>';
        return $listing_code;
    }
  13. Echtzeit
    Member
    Posted 1 year ago #

    Almost, but still not quite there :(

    Have a look for yourself: http://letsgetdigital.de/

    Everything underneath "Genre" up to the next icon is a child category, but it's not shown correctly (indented).

    Also, I tried to add

    'show_count' => 0,

    to

    // order the categories
        $r = array('orderby' => 'name', 'order' => 'ASC', 'hierarchical' => true, 'echo' => 0, 'hide_empty' => 0);
        $depth = 0 ;
        $order = bm_caticons_walk_tree(get_categories( $r ), $depth, $r );
        $order = explode(',',$order);

    but it just won't show the number count.

  14. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I must admit I was very tired yesterday. Here is a much simpler solution :

    function bm_caticons_listing() {
        echo '<ul class="theicons">';
    	put_cat_icons(wp_list_categories('title_li=&echo=0&show_count=1'),'small=false');
    	echo '</ul>';
    }
  15. Echtzeit
    Member
    Posted 1 year ago #

    So the complete code should look like this now?

    add_filter('widget_text', 'do_shortcode');
    add_shortcode('caticons_listing','bm_caticons_listing');
    function bm_caticons_listing() {
        echo '<ul class="theicons">';
    	put_cat_icons(wp_list_categories('title_li=&echo=0&show_count=1'),'small=false');
    	echo '';
    }

    Cause if that is correct, it now remedies the concerns I had before, but now the categories are shown outside the widget AND there are no icons...

    http://letsgetdigital.de/

  16. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, sorry, in fact, it should be :

    add_filter('widget_text', 'do_shortcode');
    add_shortcode('caticons_listing','bm_caticons_listing');
    function bm_caticons_listing() {
        $listing_code = '<ul class="theicons">';
        $listing_code .= put_cat_icons(wp_list_categories('title_li=&echo=0&show_count=1'),'small=false&echo=false');
        $listing_code .= '</ul>';
        return $listing_code;
    }

    But I don't know why it's not working for you... Could you execute this query and tell me the result, please ?

    SELECT * FROM  wp_options
    WHERE  option_name LIKE  'igcaticons%'
  17. Echtzeit
    Member
    Posted 1 year ago #

    Ok, the categories are back in the widget, but the icons are still missing.

    Execute the query in phpmyadmin? Did that, and this is the result:

    #1046 - No database selected

    Did I do that correct?

  18. Echtzeit
    Member
    Posted 1 year ago #

    Sorry, here are the results:

    wp_options.pdf

  19. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    What if you do that :

    add_filter('widget_text', 'do_shortcode');
    add_shortcode('caticons_listing','bm_caticons_listing');
    function bm_caticons_listing() {
        $listing_code = '<ul class="theicons">';
        $listing_code .= put_cat_icons(wp_list_categories('title_li=&echo=0&show_count=1'),'echo=false');
        $listing_code .= '</ul>';
        return $listing_code;
    }
  20. Echtzeit
    Member
    Posted 1 year ago #

    Nope, no difference from the code before, still no icons, but everything else is correct.

    I've gone back and tried the other examples from you again, and only the first two tries (the tutorial and the one after that) show the icons.

    Couldn't you maybe try to improve on those two, by just adding the postcount and the hierarchy?

  21. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    Delete all the code you used (the above code) in functions.php. This is a totally new code. I hope this'll work this time. Remove the text widget and add a category widget (the original WordPress widget). Then add the following in functions.php :

    add_filter('list_cats','bm_add_caticons');
    function bm_add_caticons($string) {
        $a = get_term_by('name',$string,'category');
        $string = get_cat_icon('echo=false&cat='.$a->term_id).$string;
        return $string;
    }
  22. Echtzeit
    Member
    Posted 1 year ago #

    OMG, I'm SO HAPPY right now. It FINALLY works again!!! Thank you so, so much! I just love the way the widget looks, it's perfect like this :) You don't know how much you want something, until it is taken away from you ;)

    Do you have any explanation what the reason for this malfunction was? Cause I sure like to know it!

  23. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    So do I ! :)

    I'm wondering : maybe I could use this for the next versions of the plugin... We'll see.

  24. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    If you want to add the icons only in the widget (all instances, in fact), you must use the code below, or you'll have icons every time wp_list_categories is called for example.

    add_filter('widget_categories_args','bm_in_widget');
    function bm_in_widget($args) {
        add_filter('list_cats','bm_add_caticons');
        return $args;
    }
    add_filter('wp_list_categories','bm_end_process');
    function bm_end_process($output) {
        remove_filter('list_cats','bm_add_caticons');
        return $output;
    }
    function bm_add_caticons($string) {
        $a = get_term_by('name',$string,'category');
        $string = get_cat_icon('echo=false&cat='.$a->term_id).$string;
        return $string;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.