How to Remove the Last Comma from wp_list_bookmarks

Today I was building a list of links on a WordPress site using wp_list_bookmarks.  I wanted to create a comma-separated list such that each link title would have a link after it.  No problem.

Except….the final link also has a comma after it.  The result looks like this:

link 1, link 2, link 3, link 4,

I want it to look like this (with no trailing comma):

link 1, link 2, link 3, link 4

To accomplish this, I used a few php functions as follows:

 '',
		'after'   => ', ',
		'echo'    => '0';
?>
  

Notice that in the $args array, I add a comma after each link. Then in the final echo line, I remove the trailing comma.

Pretty cool, eh!

Do you know of a better way to do this?

SOURCE: I found this solution on the WordPress.org forums, but I lost the link. Sorry!

Posted in ,

The Mighty Mo! Design Co.

RSS From Toby’s Blog

  • How Digital Ocean Cost Us Thousands of Dollars in a Single Day
    Here’s the rub for me: My belief is that bad stuff happens, and you need to own it. Digital Ocean definitely did not own it in this case. I wonder how the original founders of Digital Ocean would have reacted had they been in charge… For example, wouldn’t it be nice if an actual human… […]
  • Where uncertainty exists, don’t order specific.
    4 Idiot Case Studies with 2 simple age-old business lessons. The post Where uncertainty exists, don’t order specific. appeared first on Toby Cryns, WordPress Trainer in Minneapolis, MN.
  • “Now THAT was a good meeting!”
    A single effective meeting can change the course of history for a company. Imagine if you could lead effective meetings EVERY DAY! You can, but it takes curiosity & practice. This article is a good place to start your journey to a more effective you. The post “Now THAT was a good meeting!” appeared first […]

More posts from themightymo.com

New WhereAmIWearing.com, WordPress Site, is Rolling!

By | June 10, 2009

I am excited and proud to have contributed my WordPress skillz to the legendary Rule29 web shop with the new Where Am I Wearing? website!  The site is built on the WordPress framework and features just about every cool widget that you can imagine.  I was responsible for translating the design into code and had…

Notes from “Getting the Pretty Stuff In” Presentation at Flashbelt with Paul Burnett

By | June 8, 2009

Photoshop Take a bunch of photos of the exterior of a building 1) Select all the photos 2) Tools –> Open into Layers 3) “Auto-align” the layers 4) (with all of the layers selected) Layer –> Smart Objects –> Convert to smart object 5) Layer –> Smart objects –> Stack mode –> Median To stitch…

TheMightyMoo! Theme Updated! (Version 1.2.5)

By | June 1, 2009

Hello! I am pleased to let you know that I have updated TheMightyMoo! WordPress theme.  Download it here.  The most recent update: deletes the “wp_query” function that was accidentally left in the last release.  This was causing some of your installs to totally not work.  Sorry about that.  Many thanks to Paulo for pointing this…

RSS From Toby’s Blog

  • How Digital Ocean Cost Us Thousands of Dollars in a Single Day
    Here’s the rub for me: My belief is that bad stuff happens, and you need to own it. Digital Ocean definitely did not own it in this case. I wonder how the original founders of Digital Ocean would have reacted had they been in charge… For example, wouldn’t it be nice if an actual human… […]
  • Where uncertainty exists, don’t order specific.
    4 Idiot Case Studies with 2 simple age-old business lessons. The post Where uncertainty exists, don’t order specific. appeared first on Toby Cryns, WordPress Trainer in Minneapolis, MN.
  • “Now THAT was a good meeting!”
    A single effective meeting can change the course of history for a company. Imagine if you could lead effective meetings EVERY DAY! You can, but it takes curiosity & practice. This article is a good place to start your journey to a more effective you. The post “Now THAT was a good meeting!” appeared first […]