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!
More posts from themightymo.com
How to install a Cloudflare SSL certificate on Siteground
Hey there! In this video, I’ll show you how to install a Cloudflare SSL certificate on your SiteGround website. I’ve noticed that Let’s Encrypt sometimes doesn’t renew properly due to conflicts with Cloudflare, so this is a great solution. We’ll use TCwebsecurity.com as the guinea pig. I’ll walk you through the process step-by-step. Once we…
How to Download a Website from Wayback Machine
Today I ran into an issue where a bunch of website files were deleted off the server, and I was called upon to restore the old files. After first pursuing other options (e.g. backups), I landed on Wayback Machine as the next best choice. Thankfully, there’s a handy command line tool for downloading any site…
My WordPress Maintenance Process
A few quick things: My WordPress Maintenance Process Demo, Part 1 Transcript: You’ll see immediately after logging in, you see the 11 updates needed as well as some messages. I’m just gonna quickly read. It looks like this. I don’t need to worry about. Are you enjoying Monster Insights? Not really <laugh>. What’s to enjoy…