WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_cats & wp_list_pages funny output (7 posts)

  1. thornomad
    Member
    Posted 8 years ago #

    Hi,

    I have this code:

    <ul>
    <?php wp_list_cats(); ?>
    <?php wp_list_pages('sort_order=DESC&title_li='/*&exclude=4'*/); ?> <!--you can use the exclude to keep the post about damon out of there -->
    </ul>

    The output however, makes for a sore eye. The list_cats functions puts a hard return at the end of each link and before the </li> tag, effectively creating one bit of white space at the end of the li item. I am running mine in a list inline, with side borders, and this creates for awkward spacing.

    Is there any way to get the output to not put that hard return in ?

    Thanks,
    Damon

  2. niziol
    Member
    Posted 8 years ago #

    Could you post a link to a page with the oddity, I'm looking at your site and everything looks normal to me, I'm guessing you've fixed this?

  3. thornomad
    Member
    Posted 8 years ago #

    Thanks for the reply ... the actual problem is on the new theme I am developing on my local machine before I send it live. So, I don't have it up yet.

    If you look at the source, though, on the current website, for those headers links along the top with the white line division, you will notice that the first few <li> elements (blog, music, #6) do break with their </li> after a hard return.

    On IE on my PC, this looks fine (doesn't seem to care about the white space); but in Firefox on both my PC and my Mac, it makes the first three (which are from the list_cats function) and the last three (from the list_pages) have more space before the white line. It looks a little funny.

    I uploaded two pictures if you want to take a look:

    http://www.damonjustisntfunny.com/pics/tmp/

    I just didn't know if I could find somewhere in the PHP where it is saying: hard return after one and not the other.

    I am going to try upgrading to 2.0.1 and see if that makes a difference. Maybe I should use the bug reporter or something too.

    Thanks

  4. niziol
    Member
    Posted 8 years ago #

    I'm quite certain line breaks in the code make no difference, HTML will follow it's code, the default behaviour of the wp_list_pages is having the line breaks in odd places, doesn't make for pretty code, but it doesn't have an effect on the output.

    I'd guess the issue is that IE does CSS a little differently (ie: not standards compliant). Save the HTML source from the page as an HTML page, get rid of the line breaks and then view it and see if the results are the same. I've used a special IE only style sheet to give IE the different styles it needs to be functional:

    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="path/to/ie-style.css">
    <![endif]-->

    Just change th path to the IE sheet, whatever it's named and just add what needs to be different for IE in it. I strongly suspect this is the case, but let me know how it goes!

    Good luck,
    Michael.

  5. thornomad
    Member
    Posted 8 years ago #

    Great suggestion! Here is what I did:

    I opened up the source in firefox (that was displaying incorrectly), saved it as an html file, opened that file up, and went to the navigation header to get rid of the white space.

    As I had mentioned, after each closing anchor tag there is a space after the </a> and before </li> for the list_cats function (but not for the list_pages function).

    So, I went through and deleted that single space, leaving the list_pages output as it was. When I reopened the saved file in firefox, the output was displayed uniformly throughout the header (as it should be displayed, I think, but not how it is currently).

    I guess the list_cats output is making:

    <li><a href="">cat 1</a> </li>

    Instead of saying:

    <li><a href="">cat 1</a></li>

    Are you saying, though, that that space after the </a> shouldn't make the formatting change ? If so, then perhaps it is firefox that is making the error.

    Thanks,

    Damon

  6. niziol
    Member
    Posted 8 years ago #

    Is it an actual space or is it a line break after the close link? In mine, there is a line break between the closing a and li tags. If there is an actual space, not just a line break, then that would affect the rendering of the page.

    I've only started with WordPress at 2.0, so if you're using anything before that, I couldn't say what it did or didn't do, but 2.0.1 does not leave a space between the closing a and li tags, but it does leave a line break.

    I'm not sure what else I can tell you, if there is in fact a space, then may try upgrading to 2.0.1. Let me know how it's going!

    Cheers,
    Michael.

  7. thornomad
    Member
    Posted 8 years ago #

    Hi Michael,

    I do have 2.0.1 (going to move to 2.0.2 here soon). When I view the source from Firefox it appears to be a linebreak; but when I save the source as an HTM file, it is a definite space that I had to delete and, as I mentioned, that makes all the difference.

    Maybe I will try to report a bug -- I have never done that before.

    Thanks for all your help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.