WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Parent/Child Category Problem (35 posts)

  1. stchatterbox
    Member
    Posted 9 years ago #

    Hi,
    I've got 2 categories in my Blog and as the number of posts grow, I want to categorize it in a better way.
    The 2 categories: Travel & Projects
    and sub categories for Travel: Uk, China, USA
    and sub categories for Projects: Music, Architecture

    and when I make it, it displays as follows like a mess:
    >>Travel
    >>UK
    >>China
    >>USA
    >>Project
    >> Music
    >>Architecture

    how can I make it like
    >>Travel
    >>UK
    >>China
    >>USA
    and so on? Thnaks

  2. moshu
    Member
    Posted 9 years ago #

    I don't see any difference in the two lists you've posted...

  3. skippy
    Member
    Posted 9 years ago #

    Try using the hierarchical=1 option to wp_list_cats().

    Let us know if that doesn't work, or if you need more help.

  4. stchatterbox
    Member
    Posted 9 years ago #

    thanks both of you,
    skippy, actually i'm right now reading the page you gave me...been searching for a while on this topic these days.

    as for my last post....well, don't know what happen and makes no difference, maybe i'll show it clearer.

    the sub category of music and architecture tends to go RIGHT HAND SIDE a little bit.

  5. moshu
    Member
    Posted 9 years ago #

    I am using just the default
    <ul>
    <?php wp_list_cats(); ?>
    </ul>

    and everything is "styled" from the style.css
    See it here.

  6. stchatterbox
    Member
    Posted 9 years ago #

    moshu, i don know why i can't get it work like yours

    everything no matter parent or child just display like what i showed above. :(

    i'm still trying hard to read the page at http://codex.wordpress.org/Template_Tags/wp_list_cats

  7. moshu
    Member
    Posted 9 years ago #

    As I said above: take a look at the style.css file I am using. For the lists in the nav div I have:
    #nav ul {
    color: #ffedd6;
    font-weight: bold;
    list-style-type: none;
    margin: 0;
    padding-left: 3px; <=== THIS...
    }

    and for the subcats (which are embedded lists!)
    #nav ul ul li {
    border: 0;
    font: normal normal 70%/115% Georgia, 'Times New Roman', Times, serif;
    letter-spacing: 0;
    margin-top: 0;
    padding: 0;
    padding-left: 12px; <== ...and THIS
    }

  8. stchatterbox
    Member
    Posted 9 years ago #

    i think it's impossible to look at the style.css? right? it's in the forbidden place.

    i use the kubrick theme, and by defualt, the category coding in my sidebar is:

    <?php list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0,'','','','','') ?>

    well then, the subcategory is just in the same place as the categories itself.

  9. kyd
    Member
    Posted 8 years ago #

    Good day, everyone,
    I'm a newbie and having the same problem as chatterbox
    I just got WP installed an hour ago and the PHP was the same like his. Any solutions to it? to the child/parent categorizing?
    Thanks in advance,
    Kyd

  10. Minna
    Member
    Posted 8 years ago #

    Take a look at moshu's response above. The arrows mark the spots.

  11. kyd
    Member
    Posted 8 years ago #

    Minna, thanks, hehe I'm just a little newbie, and can't see this CSS code anywhere under the Kubrick theme.
    Moreover, Moshu is not using a Kubrick theme. :)
    I'm sorry and know I should have use the WIKI or search and Google/Yahoo!, but I just do not know a word from it.
    Please accept my apology for being knowing nothing.....
    Thanks
    Kyd

  12. Minna
    Member
    Posted 8 years ago #

    @kyd: No worries, I'll take a look at the Kubrick code and tell where to look :) Unless someone beats me to it.

    Code looked at
    1. Well, first of all, as a default Kubrick doesn't show categories in a hierarchical list (see wp_list_cats in the sidebar and check that hierarchical=1 not 0). If that doesn't change indenting, go to step 2.
    2. Kubrick theme assigns a class "children" to the child categories/lists so you could add in your style.css (if it isn't there already)
    ul.children {
    margin-left: 5px; /* adjust to your liking */
    }

  13. kyd
    Member
    Posted 8 years ago #

    minna
    i've added the code you said to my style.css, and tried to add it in various places, one try after the other. but just it didn't work. thanks for your help.........

  14. kickass
    Member
    Posted 8 years ago #

    stchatterbox and kyd,

    FYI, if you have FireFox installed (which you should if you're customizing WP themes and need to test them!) and add the webdeveloper extension, you can see the css styles for any page simply by using tools/webdeveloper/css/view css

    Saves SO much time, rather than trying to find the css file!

  15. Minna
    Member
    Posted 8 years ago #

    kyd, can you let us see your site?

  16. stchatterbox
    Member
    Posted 8 years ago #

    i discovered: the answer is just in WIKI. hidden somewhere.,

  17. Minna
    Member
    Posted 8 years ago #

  18. kyd
    Member
    Posted 8 years ago #

    minna
    Thankies! I'm so sorry to be so long winded. Now I understand that Kubrick Theme, by default, sets nothing for the subcategories, ie, it just looks like other parent category.

    So in this case, I need to customize the CSS individually everytime I add a child category?

  19. Minna
    Member
    Posted 8 years ago #

    @kyd: you don't need to customize CSS individually for each category (well, I'm sure you could, depending on the approach you take... :) )

    Did you check the wp_list_cats() thing I mentioned up there? If you have a parametre hierarchical=1 inside the function/tag, what are you getting out? What does the list look like now?

  20. kyd
    Member
    Posted 8 years ago #

    @Minna, actually before posting here, I searched all around in Wiki. and went to all those relevant pages telling all about the functions, php(); etc.....and then I tried the following in my sidebar.php:
    I use this kubrick default
    <?php wp_list_cats(FALSE, '', 'ID', 'asc', '', TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, '', FALSE, '', '', '', TRUE); ?>
    Changes that I did: and experimented with:
    <?php wp_list_cats(hierarchical=1); ?>
    result: parar error nothing show out in sidebar

    <?php wp_list_cats('hierarchical=1'); ?>
    result: the number of post in the category disappeared, and no changes regarding the children categories

    <<?php wp_list_cats(hierarchical='1'); ?>
    result: parsar error

    Then I came here for help, and tried again, but nothing changes either, i've made a page and take a look, experi10.madpage.com

  21. Minna
    Member
    Posted 8 years ago #

    That first bit of code works for me and it indents the subcategories and your stylesheet should be working correctly too. The bit that affects the subcategories is
    #sidebar ul ul ul, #sidebar ul ol {
    margin: 0 0 0 10px;
    }

    which is found after "/* Begin Lists" in style.css. Those numbers are in the order of top, right, bottom, left, so 10px is the margin for left hand side.

    So, currently the code you have on that page you mentioned ("wordblah") doesn't do hierarchical category lists. Try putting the first bit of code back (the Kubrick default). If even that doesn't work, are you sure "interest" is a subcategory of Uncategorized? :) The source code should look something like this:
    <ul>
    <li>Uncategorized
    <ul class='children'>
    <li>interest</li>
    </ul>
    </li>
    </ul>

  22. kyd
    Member
    Posted 8 years ago #

    @ Minna, thanks for your patience...
    The hierarchical didn't work at all, i did sidebar changes, nothing change. i Viewed my source code, and it does not look like what you said http://wordpress.org/support/topic/38864#post-219938

    I'm still wondering what happened, 14 hours already, but problem didn't solve at all.....

    maybe I'll quit now to set up a gallery first......look for a plugin first.

  23. Minna
    Member
    Posted 8 years ago #

    I just noticed you use WP1.5. I wonder if there was a bug in 1.5 regarding hierarchical listing... that's the last thing I can think of.

    Heh, actually, after searching for a bit, there is a bug in WP1.5. Would you consider upgrading? :)

    Note to self: always check the WP version first......

  24. stchatterbox
    Member
    Posted 8 years ago #

    minna, didn't wiki claimed that hierarchical listing is not working prior WP1.5? So I think WP1.5 is not a problem, although the list was not working on mine too.

  25. moshu
    Member
    Posted 8 years ago #

    As it is said in somany places, everybody should start their post by stating the version used.
    In WP 1.5 it never worked (bug). It was corrected in WP 1.5.1 and later versions.

  26. kyd
    Member
    Posted 8 years ago #

    i've upgraded already, but still no effects

  27. Minna
    Member
    Posted 8 years ago #

    At least the site you provided ("wordblah") is still 1.5...
    Did you remember to change the parametre in wp_list_cats?

  28. kyd
    Member
    Posted 8 years ago #

    i did!.....or if you could show me the how to show the code of the result i want [in kubrick]?
    sorry for my bad english too

    the sidebar...well, i did all the codes, but still nochanges.

  29. Minna
    Member
    Posted 8 years ago #

    Am I looking at the correct site? xD (http://experi10.madpage.com/blog/wordpress/)
    Could you copy-paste what you have for wp_list_cats? Did you check that there really is a parent/sub category relationship between the two categories you currently have?

  30. kyd
    Member
    Posted 8 years ago #

    @minna:
    you're viewing the correct page.

    Interest is a subcategory under Uncatogorize.

    my whole sidebar code: take a look:


    <div id="sidebar">hi, I'm Experi Mental, this is my blog and let me see if i can type anything to this part of the blog!

    • <?php include (TEMPLATEPATH . '/searchform.php'); ?>
    • <!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it.

    • <h2><?php _e('Author'); ?></h2>
    • -->

    • <?php /* If this is a category archive */ if (is_category()) { ?>
      You are currently browsing the archives for the <?php single_cat_title(''); ?> category.

      <?php /* If this is a yearly archive */ } elseif (is_day()) { ?>
      You are currently browsing the "><?php echo bloginfo('name'); ?> weblog archives
      for the day <?php the_time('l, F jS, Y'); ?>.

      <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
      You are currently browsing the "><?php echo bloginfo('name'); ?> weblog archives
      for <?php the_time('F, Y'); ?>.

      <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
      You are currently browsing the "><?php echo bloginfo('name'); ?> weblog archives
      for the year <?php the_time('Y'); ?>.

      <?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
      You have searched the "><?php echo bloginfo('name'); ?> weblog archives
      for '<?php echo wp_specialchars($s); ?>'. If you are unable to find anything in these search results, you can try one of these links.

      <?php /* If this is a monthly archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
      You are currently browsing the "><?php echo bloginfo('name'); ?> weblog archives.

      <?php } ?>

    • <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>' ); ?>

    • <h2><?php _e('Archives'); ?></h2>
        <?php wp_get_archives('type=monthly'); ?>
    • <h2><?php _e('Categories'); ?></h2>
        <?php wp_list_cats(FALSE, '', 'ID', 'asc', '', TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, '', '', FALSE, '', '', '', TRUE); ?>
    • <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
      <?php get_links_list(); ?>

    • <h2><?php _e('Meta'); ?></h2>
    • <?php } ?>

    </div>

    thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.