Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author ImportWP

    (@jcollings)

    Hi,
    Version 0.5.5 of the plugin introduces class filters to allow custom html classes to populated items. Documentation will be coming within the next couple of days but for now to add a class to your taxonomy terms, add this code into your themes functions.php file:

    add_filter( 'jcs/term_item_classes' , 'jc_term_item_classes', 10, 2 );
    function jc_term_item_classes($classes = array(), $term_id){
    	$classes[] = 'my-custom-class';
    	return $classes;
    }

    This will add the class my-custom-class to the each term populated by jc-submenu

    Hope this helps you out
    James

    Thread Starter Daniel Rodrigues

    (@danielffr)

    That didn’t work :S
    I added the code to the theme’s functions.php, changed the $classes value to the term slug and nothing has changed. After that i just pasted the code that you gave me in functions.php file, expecting to see the class ‘my-custom-class’ showing up in the li tags, still nothing happened.

    Thanks a lot for the support,
    Daniel

    Plugin Author ImportWP

    (@jcollings)

    Just to clarify, this filter only adds classes onto the dynamicly populated menu items.

    Hove you got caching on the website or server?
    Can you try to echo out some text within the function to see if it is being called? if not try changing the filter to ‘jcs/item_classes’ which will be on every jc-submenu generated item.

    Thread Starter Daniel Rodrigues

    (@danielffr)

    I think thats what i have, sub-menu items are being populated with all the terms that the chosen taxonomy has. Of course that i do this using your plugin in wp-admin/nav-menus.php .

    I’m using the local server MAMP and i think that it has caching active.

    I tried to echo something and nothing was shown. Even tried changing the filter and got the same results.

    Plugin Author ImportWP

    (@jcollings)

    If nothing is being output with the ‘jcs/item_classes’ filter, these questions may sound stupid, but:

    have you installed version 0.5.5 of the plugin?
    are you putting the code in the correct themes functions.php?

    Thread Starter Daniel Rodrigues

    (@danielffr)

    Eish, i downloaded your plugin a few days ago, I didn’t notice that the new version was already available. Sorry man, that works now.

    Thread Starter Daniel Rodrigues

    (@danielffr)

    And again, Thanks a lot for the support, really appreciate it.

    Plugin Author ImportWP

    (@jcollings)

    Cheers,let me know if you have any more problems or requests
    James

    Thread Starter Daniel Rodrigues

    (@danielffr)

    Well, i have. But i managed how to do it, but I don’t know if that it is a better solution.

    I needed that the href of the populated items to be, instead of the permalink, an hashtag with the slug. Because I need to get those posts with AJAX, so i dont the page to reload.

    To do this i went to your plugin folder and in the function populate_tax_items of the SubmenuWalker.php file I changed this:$t->url = get_term_link( $t, $value ); to $t->url = "#" . $t->slug; .

    Is there a better solution that don’t mess with your plugin files?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Add Specific class or data atribute to li tag of sub-menu.’ is closed to new replies.