duanhuo3392 2009-08-31 13:29
浏览 33

WordPress:在浏览类别时突出显示父类别

I have a category structure like this in WordPress (that is echoed with wp _ list _ categories):

Works
    Photos
        1990-2000
            Photo #1
            Photo #2
            Photo #3
        2000-2010
            Photo #1
            Photo #2
            Photo #3
    Paintings
        Watercolor
            Painting #1
            Painting #2
        Oil paint
            Painting #1
            Painting #2

I want to highlight all parent categories while browsing the category child. For example: when I am on Works->Photos->1990-2000, I want all of the categories that I've gone through to appear bold.

I use the show active category plugin ( http://www.screenshine.net/blog/1474_wordpress-plugin-show-active-category ) to achive this when I am browsing a single post.

The paramenter current _ category ( http://codex.wordpress.org/Template_Tags/wp_list_categories#Parameters ) is something that I think can be usefull...

Thanks!

  • 写回答

3条回答 默认 最新

  • dongyou7472 2009-08-31 15:16
    关注

    I am assuming that your list is composed of ul and li elements. If this is the case, you could use some javascript to set the style of the parent elements.

    element.parentNode will do the trick.

    Javascript

    element.parentNode.className = "highlighted";
    

    CSS

    .highlighted { font-weight: bold; }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据