WordPress.org

Forums

Where do i find this code? (3 posts)

  1. norgaards
    Member
    Posted 7 years ago #

    Hi there,

    I have just started using wordpress. I use the rainbow-style theme. I would like it to show the number of posts in each category. I learned that i should use this code:

    wp_list_cats('sort_column=name&optioncount=1&hierarchical=0');

    I am not a programmer and couldn't find out in which file this code is. I searched for the string with windows search function but i didn't return anything.

    I hope that someone here could tell me in which file this code is located. Is it in a theme file or in a wordpress file. Is it already there and should i just change it to above or should it be added somewhere?

    Thanks
    John

  2. Chris_K
    Member
    Posted 7 years ago #

    The code is in your theme's directory. I'm not familiar with the theme and you didn't share a link... but for many themes, the category list is in the sidebar.php file.

    If your theme already lists category, it's probably already using the wp_list_cats function and you'd just need to add: &optioncount=1 to it.

  3. norgaards
    Member
    Posted 7 years ago #

    Thanks but &optioncount=1 is already enabled. It uses wp_list_cats in sidebar.php:

    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0&list=0'); ?>

    In the default theme this function is used in sidebar.php:
    <?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?>

    With this categories is shown correctly:
    Abort (2)
    - child1
    - child2

    etc. But using wp_list_categories in sidebar.php of the rainbow_style theme doesn't work as it should. It shows them this way:
    Abort
    (2) - number of posts on a new line

    and the subcategories
    -subcategory1
    -subcategory2

    isn't shown. I understand that wp_list_cats is a deprecated function. Do you know what to add to the wp_list_categories function to make the categories appear like this:

    Abort (2)
    - subcategory1
    - subcategory2

    Thanks
    John

Topic Closed

This topic has been closed to new replies.

About this Topic