WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_[foo] without LI tags?? (15 posts)

  1. ygg
    Member
    Posted 7 years ago #

    Hi there - in the older versions of WP, there were now-deprecated functions to produce a list of items (i.e., categories, archives) WITHOUT the "li" tags. I would very much prefer to keep my formatting out of my functions to begin with, but regardless of that I do NOT want those items in list format.

    I looked at the new functions that are supposed to replace both the listing and non-listing versions of the old functions, but there's no apparent way for me to tell it not to spit out LI tags.

    Any help would be very much appreciated.

    ygg

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Which functions in particular are you talking about? There's ways in most all of them to specify your own formatting.

  3. ygg
    Member
    Posted 7 years ago #

    Well, the wp_list_pages function appears to spit out an LI whether I like it or not (I str_replaced the tag after turning off echo, seeing no other recourse there - horrible solution, but no other presented itself.)

    wp_get_archives is great but looks highly idiosyncratic - why the other functions don't have the custom html argument is a bit confusing since it's extremely handy.

    wp_list_categories has the "style" argument but will still include markup (br tags) if set to 0.

    By and large, I have three problems with these functions, which are all, essentially, sidebar functions primarily:

    1. Markup is included in function output, thereby conflating presentation and functionality and removing presentation from my complete control.

    2. Visual presentation of these functions is nigh-identical, particularly in the default state, but control over that presentation and argument structure/presence varies wildly from function to function.

    3. At least one of the functions (wp_list_pages) does not appear to have any mechanisms by which I can alter presenation and markup output.

    It's certainly a step up from earlier versions, where I had to yank & manipulate output via PHP's output buffering functions, but it's still a bit mad. If I've missed something in terms of control over presentation, please let me know!

    thanks,
    ygg

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Well, the wp_list_pages function appears to spit out an LI whether I like it or not

    True. wp_list_pages has no option to disable the LI tags. That may be added in a future version, if you put a note into trac about it.

    wp_get_archives is great but looks highly idiosyncratic - why the other functions don't have the custom html argument is a bit confusing since it's extremely handy.

    While it's difficult to say for certain, I imagine that that will eventually go away, in favor of more customization possibilities. wp_get_archives has been around a long time though.

    wp_list_categories has the "style" argument but will still include markup (br tags) if set to 0.

    Without some markup, you get a single list of run-on words. I cannot see why anybody would want that.

    If I've missed something in terms of control over presentation, please let me know!

    What you missed is that these functions were not really designed to be consistent with one another, but to offer functionality that people needed/wanted/used. They're mainly defined by usage and people saying how they want them to work.

    Mentioning your points here is, well, pointless. Make a bug report in trac. Somebody might look at it and change it. Or change it yourself and submit a patch.

  5. Root
    Member
    Posted 7 years ago #

    Otto42 I do not agree with your approach or response to this question. The whole business of markup and inconsistent functions in the menu in the nested lists from hell is very real. It is a snakepit of CSS voodoo which is very frustrating for the discerning end user. It has been like that since Year Zero.

    Without some markup, you get a single list of run-on words. I cannot see why anybody would want that.

    It is not necessary for you to understand what this guy is doing and why. This is a very useful feature. Or it would be.

    I do not think the user has *missed* anything. I think he is right on the money.

  6. ygg
    Member
    Posted 7 years ago #

    I'm not sure that submitting a holistic concept such as "separate presentation from data, please" to trac would really be a useful approach :)

    Obviously a *string* of run-together words would not be useful. A LIST, however, would be extremely useful. I would then be able to parse by the delimiter and present the list in whatever fashion I so chose.

    In my original post, I was mostly hoping someone would say "oh, yeah - we haven't really updated the documentation too well yet, here's how you do that in 2.x." Clearly that was hoping for too much. I like WordPress enormously, and it does most of what I want fairly simply and easily. However, it seems that there was some lack of overall design during the development - and, more surprisingly, the development of a serious upgrade version.

    I have neither the time nor the development skill to rewrite what would be a significant chunk of code - code that would also seriously impact theme development. I do think that the API could use some re-examination, but that's clearly not for me to be doing.

    ygg

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Obviously a *string* of run-together words would not be useful. A LIST, however, would be extremely useful. I would then be able to parse by the delimiter and present the list in whatever fashion I so chose.

    I guess I fail to see the advantage here. If you're just going to parse the list anyway, why not just call get_pages() directly? Then do whatever you like.

    $pages = get_pages();
    foreach ($pages as $page) {
    echo $page->post_title;
    }

    That's just a simple example, of course, but if you want the pages in plain formats, why have special functions specifically for that when you can just retrieve the array of pages directly?

    get_pages() has all sorts of available options. You can sort them, you can limit them by authors or page numbers, you can get them hierarchically, etc.

    I admit that wp_list_page() should have more options like before, after, between, etc, but really, it's not as bad as you make it out to be. Nobody's added those because nobody needs them too badly. I would indeed like all the wp_list_* functions to share a common argument and formatting system, of course. But until somebody actually goes and does it, it's not there. :)

  8. Doodlebee
    Member
    Posted 7 years ago #

    I've stripped the LI tags from my sidebar lists before. It's actually the first plugin I ever wrote. It's actually pretty easy to do - and probably better to use it as a plugin rather than hack the core code - but it uses core code as the basis for it. Let me see if i can dig up how I did it...

    EDIT: it was for an older version of WP by the way - 2.0.5, I believe. I'd have to do some research on 2.1.1 to see if it would work, but I know it can be done.

  9. Doodlebee
    Member
    Posted 7 years ago #

    Aha - here it is. Yeah, my plugin wouldn't work with 2.1.1 - but I can see what you can do to make it work for what you want.

    You'd have to open wp-includes/bookmark-template.php. Do a search for <ul> and it'll take you pretty close to the line you'd need - there, line 233 is where you start. Get rid of the <li> stuff n that area - you'll see them.

    Of course you can write this up as a plugin and it would be better (like I said) - basically just copy this file and rename the function to something else, make your desired edits and then call *that* in instead of wp_get_links.

    Hope that helps ya...

  10. paulpicauly
    Member
    Posted 7 years ago #

    Instead of letting WP output my categorie list directly to my blog I chosed to put it in an array so you can change it anyway you want with php. The result is a plugin with help file that can be found here.

  11. thepete
    Member
    Posted 7 years ago #

    I've always felt that WP was a bit li and ul crazy. I had never seen either tag before I started using WordPress in 2004 and I've had some kind of web presence since 1996. I've always been a fan of less coding=better coding. But that's just me.

    Thanks for the plugin Paul, hopefully it will do the trick!

    gave it a whirl, but no go--unless there's a special tag for it, I can't get it to work :(

  12. whooami
    Member
    Posted 7 years ago #

    did you read the help.txt?

  13. Root
    Member
    Posted 7 years ago #

    And incidentally a single run of undifferentiated links can be very handy. display: block gets them back in order in a jiffy. And for horizontal menus the ul li ul li mess makes no sense at all.

  14. conejito
    Member
    Posted 6 years ago #

    I'm new to wordpress (not to php) and first must say I'm impressed. Great tool, I decided to use it as a CMS+blog tool, and delved into it for the last couple of days. But as a newbie I must say this strange obsession with ul and li tags is what struck me as the most odd about it. It does violate a fairly basic principle, the separation of design and content. I use DHTML submenus on my site and wrote this quick 'n dirty function that returns an array of arrays with the pages/subpages, and then derive the necessary javascript to put in header.php. But it made me feel somewhat dirty and I don't understand why that functionality isn't in a tool that looks so well developed.

  15. Leodore
    Member
    Posted 6 years ago #

    Hey,
    I was reading this post and it is kinda related to my problem.
    The problem I am faced with is that I wan't to create a dropdown menu which only uses css (instead of the solutions out there that use CSS and javascript) to organise wordpress pages and subpages.

    there are heaps of great CSS only solutions here: http://www.cssplay.co.uk/menus/drop_examples.html

    The only problem is that these menus use a different markup to the wp_list_pages() produced by wordpress.

    I have taken one example and have broken it down to its essentials http://www.dingo-style.com/output.html.

    and from this I have worked out what markup I would like outputted depending on whether or not each page contains subpages or not.
    The problem I am faced with is that I don't know enough about wordpress or about PHP in order to firstly determine whether or not a page has subpages and secondly adjust the outputted markup accordingly.

    If you have any ideas, your help or comments would be greatly appreciated

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags