• First of all, apologies if this is not really a heavy “WP Development” topic, but it’s not really “Fixing WP” and didn’t seem to fit the other categories. While I’m not a hard-code developer, I like to learn and have enough knowledge to be dangerous. (uh-oh)

    I’m trying to control the number of categories in the Category list of my sidebar. From here:
    https://developer.ww.wp.xz.cn/reference/functions/wp_list_categories/

    I see there are parameters like show_option_all and show_option_none but nothing that lets me set the number of categories displayed in the list. I’d like to show, say maybe 5 of the top categories, or even better, control/hard code exactly which categories with a “see all categories” at the bottom of the list.

    The site is http://www.madnessmuseum.com … using the Twenty Sixteen Theme, up-to-date on WP, theme version, blah blah.

    In in the interest of learning, and maybe making it more complicated for myself (why?!?!), I’m also looking to do this within the current theme. In fact, a lot of themes I’ve explored still don’t seem to provide the ability to control the number of categories. I’m also trying to avoid scouring for a one single plug-in that does just what I want for category list.

    Can anyone help?? Thanks in advance!

    Lee

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator t-p

    (@t-p)

    Thread Starter coolpillows

    (@coolpillows)

    Thanks t-p! I think I glanced at this in an original search but probably shied away b/c it either offers the dropdown solution which is not what I want OR, go ahead, make yourself a custom widget. This is the good & bad thing about WP…so many options but there’s a widget for everything. Let’s see what else comes up here on the forum or maybe I’ll hack out a widget for myself when I’m not darning my socks or sumpin. 🙂

    Moderator bcworkz

    (@bcworkz)

    That SE post would scare away many looking for a simple solution. If you were able to filter out extraneous information (not a simple task), the answers you seek are there, just not that apparent. For example, the dropdown output style has nothing to do with the query arguments to get categories in a particular manner.

    The other thing that’s not clear is you can supply any get_terms() arguments in wp_list_categories() even though they are not listed in the wp_list_categories() arguments descriptions. This means you can just supply the “number” argument and it’ll be passed on through and used in the eventual get_terms() call several layers down the call stack.

    The other useful take away from the SE post is you probably want to order the list by “count” so the most common categories show up in the shortened list.

    One last thing, thank you for giving the appropriate forum to post in some consideration. Many forum titles are virtually brand new and the criteria of what goes where beyond what each description says has not been defined. Anything in a gray area such as yours would be given the benefit of doubt. You’d be fine either way. AFAIC, if you are writing custom code, you are a “Developer” in these forums 😉

    Thread Starter coolpillows

    (@coolpillows)

    shucks thanks bc. i didn’t swear i was going to write custom code…just considering it. but benefit of the doubt is better than saying, ‘how dare u post this you noob!’
    and i just realized there was a typo above and i meant to say, hard-core developer, not hard-code dev. in some circles, that alone would get sent to banished beginner forum for life. #hardcoreforlife 😉

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Changing category count in widget’ is closed to new replies.