Make WordPress Core

Opened 14 months ago

Closed 7 months ago

#24428 closed defect (bug) (fixed)

wp_list_categories 'show_option_all' have not class element

Reported by: Alexufo Owned by: nacin
Milestone: 3.8 Priority: normal
Severity: normal Version: 2.2
Component: Template Keywords: has-patch
Focuses: Cc:


wp_list_categories 'show_option_all' link to all categories .
But this link have not class like overs li elements.

Try this

	<? $args = array(
	'show_option_all'    => 'All',
	'orderby'            => 'name',
	'order'              => 'ASC',
	'style'              => 'list',
	'show_count'         => 1,
	'hide_empty'         => 1,
	'use_desc_for_title' => 0,
	'child_of'           => 0,
	'feed'               => '',
	'feed_type'          => '',
	'feed_image'         => '',
	'exclude'            => '',
	'exclude_tree'       => '',
	'include'            => '',
	'hierarchical'       => 1,
	'title_li'           => '',
	'show_option_none'   => __('No categories'),
	'number'             => null,
	'echo'               => 1,
	'depth'              => 0,
	'current_category'   => 1,
	'pad_counts'         => 0,
	'taxonomy'           => 'category',
	'walker'             => null
); ?>

<?php wp_list_categories($args); ?>

You will get

  <!--This li element have not class --><li><a href="">All</a></li>
  <li class="cat-item cat-item-35"><a></a></li>
  <li class="cat-item cat-item-4"><a></a></li>

Attachments (1)

24428.patch (1019 bytes) - added by SergeyBiryukov 14 months ago.

Download all attachments as: .zip

Change History (9)

SergeyBiryukov14 months ago

comment:1 SergeyBiryukov14 months ago

  • Component changed from Query to Template
  • Keywords has-patch added
  • Version changed from 3.5.1 to 2.2

24428.patch adds .cat-items-all and .cat-items-none.

A workaround is .categories > ul > li:first-child.

comment:2 Alexufo14 months ago

Thanks! But all li elements highlighted by .current-cat class.

This class not apply at 'show_option_all' => 'All' link.

  <!--This li element didn't has class if activated like others --><li class="cat-items-all"><a href="">All</a></li>
  <li class="cat-item cat-item-35"><a></a></li>
  <li class="cat-item cat-item-4"><a></a></li>

comment:3 SergeyBiryukov14 months ago

Well, it's not really a category, so .current-cat doesn't seem applicable here.

We could probably add .current-list-item class (similar to .current-menu-item for nav menus). Not sure if that's necessary though, a simple workaround for a theme that uses body_class() is .home .cat-items-all (with 24428.patch) or .home .categories > ul > li:first-child.

comment:4 Alexufo12 months ago

and what now? How to send this request to core?

comment:5 SergeyBiryukov10 months ago

  • Milestone changed from Awaiting Review to 3.7

comment:6 nacin9 months ago

  • Milestone changed from 3.7 to 3.8

Honestly curious what the use case here is.

comment:7 Alexufo9 months ago

nacin , look here serebniti.ru

You will see second menu with rubrics. First rubric is all. first li element hase been need the class.

Last edited 9 months ago by Alexufo (previous) (diff)

comment:8 nacin7 months ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 26588:

wp_list_categories(): Add cat-item-none and cat-item-all classes to the none/all options.

props SergeyBiryukov.
fixes #24428.

Note: See TracTickets for help on using tickets.