WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_list_bookmarks Not Honoring My Exclude Category (17 posts)

  1. Joni
    Member
    Posted 5 years ago #

    We're getting ready to do a site launch in the next 24 hours and this page is misbehaving.

    http://blusd.mytestbed.com/links/

    I've got a separate links.php page with this code in it, to call all the bookmarks except "Member Bands" which is ID 2.

    <?php wp_list_bookmarks('exclude=2'); ?>

    We also have a separate Member Bands page template with this code, which shows only the links in the "Member Bands" category, but with descriptions and some other formatting. It's working beautifully. CRAP!! Now neither template is working! Arrhghgh!

    The code:
    <?php wp_list_bookmarks('include=2,title_li=&show_description=true&between=: '); ?>

    The page:
    http://blusd.mytestbed.com/member-bands/

    What am I doing wrong with the Links page? Do I need to specifically INCLUDE all the other categories except ID 2?

    That's gonna be a big PITA when it's all said and done, since there will eventually be a lot of categories and these folks shouldn't have to go in and add another cat ID to the "include" list each time they create a new one.

  2. Joni
    Member
    Posted 5 years ago #

    I "unpublished" the Links page since it was messing with the Member Bands page .. hoping to get the Member Bands page back. Nope. It's completely hosed. What's up with this?!?!?

  3. iridiax
    Member
    Posted 5 years ago #

    From the Codex:

    exclude
    (string) Comma separated list of numeric bookmark IDs to exclude. For example, 'exclude=4,12' means that bookmark IDs 4 and 12 will NOT be returned or echoed. Defaults to (exclude nothing).

    I just use the category=1,5,6 parameter to specify which bookmark categories show.

  4. Joni
    Member
    Posted 5 years ago #

    Yes, I did that with the member-bands page and it was working before I added another page using EXCLUDE. I have read the codex backward and forward and the code I posted for each page SHOULD work, should it not? As explained, these folks are going to be adding categories and I don't think they should have to remember to ADD a string of ID numbers (once they've even found them) to the page template before doing so, do you?

    Any thoughts as to WHY this isn't working? And why, now all of a sudden, the original Member Bands page isn't working anymore, even tho I deleted the links page?!?!?

  5. Joni
    Member
    Posted 5 years ago #

    To clarify for you:

    Desired:
    Links Page #1: INCLUDE ONLY ID FROM ONE CATEGORY (2)
    Page code:
    <?php wp_list_bookmarks('include=2,title_li=&show_description=true&between=: '); ?>

    Result (not working):
    http://blusd.mytestbed.com/member-bands/

    Desired:
    Links Page #2: INCLUDE ALL LINKS EXCEPT THOSE FROM CATEGORY 2
    Page code:
    <?php wp_list_bookmarks('exclude=2'); ?>

    Result (not working):
    http://blusd.mytestbed.com/links/

  6. Joni
    Member
    Posted 5 years ago #

    Hookay. This is getting REALLY WEIRD. First of all, I was able to recreate the Member Band link listing by deleting all the other categories, which forced it to display member bands. I swiped the source code for that listing and just created a static page. (So much for the beauty of content management, huh?)

    Then I decided to restore those four new categories. Now I've also decided to just INCLUDE THEM (to hell with the client's convenience at this point, I just want the site up and running).

    So I changed the code in the links template to this:
    <?php wp_list_bookmarks('include=12,13,14,15'); ?>

    And here's what I get now: Notice that even tho ID 2 is EXCLUDED specifically, it still appears, and look what's happening to the links!!!
    http://blusd.mytestbed.com/links/

    WTF, WP?

  7. iridiax
    Member
    Posted 5 years ago #

    include and exclude here apply to individual bookmarks not bookmark categories.

  8. Joni
    Member
    Posted 5 years ago #

    damn i'm dumb. thanks iridiax!!! let me go check your theory! {{slinks away in shame}}

  9. Joni
    Member
    Posted 5 years ago #

    Yep, works like a charm. In a perfect world, I'd have prefered them not to have to go in and manually add those cat IDs when they add categories, but heh, I'll take what I can get and maybe they won't add any new cats. :)

    http://blusd.mytestbed.com/member-bands/
    CODE:
    <?php wp_list_bookmarks('category=2&title_li=&show_description=true&between=: '); ?>

    http://blusd.mytestbed.com/links/
    CODE:
    <?php wp_list_bookmarks('category=12,13,14,15'); ?>

    Iridiax, contact me off list (check my profile) please!!

  10. iridiax
    Member
    Posted 5 years ago #

    damn i'm dumb. thanks iridiax!!! let me go check your theory! {{slinks away in shame}}

    LOL. You name a mistake, and I've probably made it myself. ;-) I couldn't get include/exclude to work right either and then ended up using category.

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

    Use the 'exclude_category' parameter if you want to exclude whole categories.

    wp_list_bookmarks('exclude_category=2');

  12. Joni
    Member
    Posted 5 years ago #

    Thanks Otto. I'll check that out. Maybe I didn't scroll down far enough in the codex to see that. (cuz it's hard to see with egg on your face!) :)

  13. brainspiral
    Member
    Posted 5 years ago #

    Hi. What if I want to use wp_list_bookmarks to display the union of bookmarks in two different categories. I know if I pass category=1,2, it will display all the bookmarks in BOTH category 1 and category 2. And I've tried passing something like this:
    array('category__and' => array(51,60))

    But it seems to be completely ignored by wp_list_bookmarks.

    Perhaps wp_list_bookmarks has some other limitations.

  14. ekanna
    Member
    Posted 5 years ago #


  15. ekanna
    Member
    Posted 5 years ago #


  16. ramon fincken
    Member
    Posted 5 years ago #

    Small update, has anyone tried exclude_category instead of exclude?

    See also: http://www.ramonfincken.com/permalink/topic142.html

  17. Birdie
    Member
    Posted 4 years ago #

    Don't make the same mistake as I was....I couldn't figure out the category ID number. Looking at the admin panel for Bookmark Categories, I saw the number 6, so was using that number. Duh - that was the number of bookmarks under that category.Finally figured that out, but couldn't see anywhere that told me what the category ID number was. Finally noticed if I clicked it the category ID displayed in the URL.

    Voila - exclude_category now works! So I will admit having a dumb moment in hopes it helps everyone else struggling with this!

Topic Closed

This topic has been closed to new replies.

About this Topic