Forums

[resolved] How to get Classes to wp_list_categories? (8 posts)

  1. stakkit
    Member
    Posted 6 months ago #

    I must give the class term-<?php the_ID(); ?> to wp_list_categories:

    <ul>
      <li class="all"><a href="#" class="all current" data-value="all"><?php _e('All', 'framework'); ?></a><span>/</span></li>
       <?php
        wp_list_categories(array(
                'title_li' => '',
                'taxonomy' =>
                'skill-type',
                'walker' => new Portfolio_Walker(),
                'show_option_none' => ''
            )
        ); ?>
    </ul>

    Is there anyone who can help me?
    Thank you and sorry for my bad english!

  2. alchymyth
    The Sweeper
    Posted 6 months ago #

    your list seems to use a custom walker (a custom functions to build and show the list):
    'walker' => new Portfolio_Walker(),

    try to find this function Portfolio_Walker() possibly in functions.php of your theme (what theme are you using?)

    then paste the full code of that function into a http://pastebin.com/ and post the link to it here (how to: http://codex.wordpress.org/Forum_Welcome#Posting_Code )

  3. stakkit
    Member
    Posted 6 months ago #

    thank you alchymyth!
    here the link:
    http://pastebin.com/fvMu9hwy

  4. stakkit
    Member
    Posted 6 months ago #

    when I click on view source code from the browser I see only <li> tag without the class.

  5. alchymyth
    The Sweeper
    Posted 6 months ago #

    can you indicate where the class has to be added in the menu:

    <ul>
      <li class="all"><a href="#" class="all current" data-value="all"><?php _e('All', 'framework'); ?></a><span>/</span></li>
       ....

    is the class supposed to use the post ID or the category ID?

  6. stakkit
    Member
    Posted 6 months ago #

    I would like a menu as:

    <ul>
        <li class="all"><a href="">All</a><span>/</span></li>
        <li class="term-1"><a href="" data-value="term-1">Red</a> <span>/</span></li>
        <li class="term-2"><a href="" data-value="term-2">Blue</a> <span>/</span></li>
        <li class="term-3"><a href="" data-value="term-3">Yellow</a> <span>/</span></li>
        <li class="term-4" ><a href="" data-value="term-4">Green</a> <span>/</span>
        </li>
    </ul>

    I think that should be something like '<li class="term-'.$category->term_id.'" '

  7. stakkit
    Member
    Posted 6 months ago #

    but I do not know how use it.

    [please be more patient - do not bump]

  8. stakkit
    Member
    Posted 6 months ago #

    I solved my problem with: $output .= '<li class="term-'.$category->term_id.'" ';

Reply

You must log in to post.

About this Topic