• Resolved illhome

    (@illhome)


    hello.

    i am useing this code to display my categoy-links:

    <?php
    wp_list_categories('orderby=name&show_count=1&title_li=');
    ?>

    this code is perfect and displays the category-links fine but, as you might have noticed i enabled the show_count feature and that is exactly where my problem is.

    the category-links are each in a little rectangular box that is coloured in some colour. all other entries like the blogroll and the meta-data links are done in the same way.

    however the little count number has now changed the look and the navigation does no longer look any good. inbetween each category-link there is a line where there is the countnumber.

    i would at least have liked to have this number next to the category-link and not underneath. to give you an optical idea of what i am talking about i will create somekind of drawing to show you …

    code without numbers:

    -------------------
    | categroy link 1 |
    -------------------
    | category link 2 |
    -------------------
    | category link 3 |
    -------------------

    you will be able to tell that the lines indicate the surrounding box … anyway if i use the code to display the count-number it looks something like this:

    -------------------
    | categroy link 1 |
    -------------------
    (15)
    -------------------
    | category link 2 |
    -------------------
    (8)
    -------------------
    | category link 3 |
    -------------------
    (25)

    as you can well imagine that looks damn awfull and i would much rather like to have the link and the number in one line together. the number (count) does not have to be part of the link but at least in the same line and that is my problem. i just can’t figure out how to do that.

    if you have any ideas please to not hesitate to describe your thoughts or possible solutions here.

    thank you kindly & best regards

Viewing 12 replies - 1 through 12 (of 12 total)
  • tweaking it to display right with post count turned on is possible, but we wouldn’t know where to start helping you if you don’t show us your blog.

    Thread Starter illhome

    (@illhome)

    hello,

    well what code segments would you require ? my blog is not online yet due to testing in an offline localhost version, so i can’t really show you what i mean.

    i can gladly however post codesegments that could help or even upload the style for download/demonstration but keep
    in mind it is unfinished!

    sofar it consists of 8 php files, 10 css files, 3 gif files, 2 png files and 1 ico file

    however all the css files are identical appart from one colour. i use a highlight colour and wanted the user to decide what colour will be the highlight colour.

    either i can post codesegments of what you need to know or as i say i can upload the style as a zipfile somewhere.

    if it leads to the result of having it displayed in the way i envisioned it then i would gladly help in any way as best i can.

    best regards

    Thread Starter illhome

    (@illhome)

    hello.

    i have now uploaded the style as a *.zip file and it can be downloaded here: zipfile … rightclick and save as

    please keep in mind three very important things:

    01. it will not be there downloadable anymore when my problem has been solved.
    02. a few elements will not display correctly without using certain tags which i made by editing the quicktags.js … this mainly concerns the code, quote and spoiler features
    03. there is a textfile included that is called read_me_first_important.txt … it is very important that you do this before you activate the style. it is a quick edit of the header.php in the theme because there are some links in there that lead to the css files and to the ico file. if you do not edit this then the style or theme will not work correctly

    once you have activated the theme then please start your test and look at the sidebar. see in there the dropdown to the archives with months and behind it the count-numbers and then look directly under that dropdown at the category section and you will see that what i described in my question right at the top.

    look below at the blogroll links and you will notice the difference and will see why i am so disappointed in what it looks like now.

    if you know where i would have to edit or what i would have to edit then please help out as it is very upsetting if it looks so untidy.

    thanks in advance for all the help.

    best regards.

    Thread Starter illhome

    (@illhome)

    hello,

    i guess nobody can or wants to help me in this issue?

    i can’t do more than post the code (see above complete code as zipfile-link) and there is no mention of anything to do with the alignment of the count-numbers in the documentation of wp_list_categories
    all it says there is just how to activate or deactivate the count.

    that it destroys all of the design by activating it doesn’t seem to bother anyone but me. i am not pleased with the look of my navigation with the count activated and if noone cares to look into it and maybe try and help me find a reasonable solution then i will have to deactivate the count and will always be dissatisfied about the missing feature that would have rounded off my style (theme) quite nicely.

    so if you have any idea at all on a workaround then please help me out. it can’t be all that difficult for all the experts?

    kind regards

    Your zip isn’t very helpful, as it contains no core files ;).

    Open your classes.php and look for this in the class Walker_Category:

    if ( isset($show_count) && $show_count )
    $link .= ' (' . intval($category->category_count) . ')';

    Copy these 2 lines from where they are and look for the following:

    $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';

    Maybe that line is just $link .= $catname.'</a>';, but either way you have to split it up and insert the if-statement i mentioned above. In the end, it will look like:

    $link .= $cat_name; // (or that one with apply_filters('..')
    if ( isset($show_count) && $show_count )
    $link .= ' (' . intval($category->category_count) . ')';
    $link .= '</a>';

    Be done ;). But please, backup your classes.php in case you mess it up *g*. And can anyone tell me, why the backticks don’t work with blockquote here?

    Thread Starter illhome

    (@illhome)

    hello,

    well that brings me at least one step furhter. your tip is great and i did exactly that what you said with one small addition: the closing link command. my code in the classes.php now looks like this:

    $link .= '>';
    // $link .= $cat_name . '</a>';
    $link .= $cat_name; // (or that one with apply_filters('..')
    if ( isset($show_count) && $show_count )
    $link .= ' (' . intval($category->category_count) . ')';
    $link .= '</a>';

    no this has brought the following result:

    ------------------------
    | categroy link 1 (15) |
    ------------------------
    (15)
    -----------------------
    | category link 2 (8) |
    -----------------------
    (8)
    ------------------------
    | category link 3 (25) |
    ------------------------
    (25)

    the count-numbers are now part of the link which is okay but would not have been important but it is fine. however the count-numbers are still beneath the box aswell as being in the link.

    if i now edit the sidebar.php again and take the ‘&show_count=1’ away again then the count-numbers will be gone again from both spots. meaning no longer in the link and no longer underneath the link box.

    this means there is still some kind of ‘flaw’ in somewhere. by the way: all core-files have not been modified in any way (appart from the quicktags.js) … everything else has up till now been out of the box standard wordpress 2.2.1

    this was my first major edit to any core files at all.

    now that i now what is meant by needing more information to help i can say if you install a offline version of wordpress 2.2.1 out of the box then you would have the same as me.

    the only differences would be my own quicktags.js and now the classes.php

    so that brings it all to a understandable level i guess.

    now my final question would be: how can i get away the numbers now that are still below. screenshot of that section now at the moment:
    screenshot of a few minutes ago (11KB)

    any ideas or is there now solution for that at all?

    it would basically be enough if the pink numbers were in the same line as the link. having the number in the link is cool but would not have been important. it is now essential to get either the pink numbers away completely or to find another solution to the problem.

    but in any case: thank you Sivar for the great idea. as you can see it is a partial improvement and therefore i am very happy that you came up with this idea. if you have the time and want to follow up on the other little bug, then i would really be very happy. thank you very much.

    kind regards.

    You didn’t delete the if-statement at the place where it was before. But I guess I didn’t explain it properly, sorry :).

    So don’t just copy it, but also delete the original one. Just to clearify… by if-statement, i mean the following:

    if ( isset($show_count) && $show_count )
    $link .= ' (' . intval($category->category_count) . ')';
    Thread Starter illhome

    (@illhome)

    hello.

    thank you very much Sivar. your last tip with the deleting of the if-statement was the final missing bit in the problem. this solution is great.

    i have now not only got the count-numbers in one and the same row as the category links but also directly part of the link. very good result indeed.

    thanks for all the help.

    i will mark this topic as resolved.

    kind regards

    I found a workable solution

    if ( isset($show_count) && $show_count )
    $link .= ‘<span>(‘ . intval($category->category_count) . ‘)</span>’;

    this puts a < span > tag around the count then for CSS i used this

    position: relative;
    float: right;
    top: ;
    left: ;

    gspark, i think i need your help with this…I’ve tried these instructions, and yours but i cant get the post counts to display next to the category, instead they display below the category…

    your instructions are kind of difficult to follow, where should I put that script you suggested, and what should I name the element in my CSS class that should feature those characteristics?

    $link .= $cat_name;
    if ( isset($show_count) && $show_count )
         $link .= '<span id="pagecount"> (' . intval($category->count) . ')</span>';
    $link .= '</a>';

    I added a span tag so that I can style the color of the page count differently then the html, it works well.

    now in the css

    #pagecount {
    	color : #34859c;
    }

    I could not get the above to work until I removed the code “display: block;” in the columns section of my style sheet:

    I then replaced the code mentioned above in the earlier post in classes.php with

    if ( isset($show_count) && $show_count )
    $link .= ‘<span id=”pagecount”> (‘ . intval($category->count) . ‘)</span>’;

    and added to the style sheet:

    #pagecount {
    color : #34859c;
    }

    It works perfectly now without the count being part of the link.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘wp_list_categories problems with display in sidebar. need help’ is closed to new replies.