Forums

Categories not showing in sidebar (5 posts)

  1. Matthew2D
    Member
    Posted 1 year ago #

    In the sidebar only the uncategorized category is showing. Why?

  2. IshaanRawat
    Member
    Posted 1 year ago #

    can you give me your site link/???

  3. jnhghy
    Member
    Posted 1 year ago #

    what theme are you using? are you using a custom post type?
    Usually you have this issue if you are using cusom post types like ad_listings for ad listings websites some plugins also create custom post types.
    what plugin do you use to create your posts?

  4. IshaanRawat
    Member
    Posted 1 year ago #

    The categories, to my knowledge, have to have a post categorized in them to show up.

    So if you have a category called 'fish' but you haven't posted any posts labeled as 'fish', then the category won't show up.

  5. IshaanRawat
    Member
    Posted 1 year ago #

    or if you want them whether they are empty or not then just follow the instructions.... It might help--->

    You need to edit a line in your theme's header.php file.

    1. In your WordPress admin panel, go to Appearance > Editor
    2. On the right, under Theme Files, select the "Header" link (for the header.php file)
    3. Do a search (CTRL+F) for "list_categories"
    4. You should come to a line that looks something like this:

    <?php wp_list_categories('title_li=&exclude=' . $GLOBALS[asides_id]) ?>

    (The stuff between the parentheses will vary by theme.)

    5. Add "&hide_empty=0" (without the quotes) right before the last apostrophe (the '). (Basically, between these apostrophes is where you can add arguments. Arguments are separated by ampersands (&).

    So in the above example, the edited line looks like:

    <?php wp_list_categories('title_li=&exclude=&hide_empty=0' . $GLOBALS[asides_id]) ?>

    6. Click Update File and check your website. All categories should now show, whether they have posts or not.

    Note: This may also add the dreaded "Uncategorized" category item. If you want to exclude that, find its category ID* (it's probably "1"), and edit the line so it includes "&exclude=1" (assuming 1 is the ID) like this:

    <?php wp_list_categories('title_li=&exclude=&hide_empty=0' . $GLOBALS[asides_id]) ?>

    * How to find the category ID: http://www.wprecipes.com/how-to-find-wordpress-category-id

    Also, this link lists all the arguments you can add to the wp_list_categories function. http://codex.wordpress.org/Template_Tags/wp_list_categories. For instance, the order_by argument allows you to customize the order in which the categories are displayed (e.g., you can sort them by their IDs to give you full control). By default, it looks like they're sorted alphabetically.

    This might help...
    [ Signature moderated. ] Ishaan Rawat

Topic Closed

This topic has been closed to new replies.

About this Topic