Home » Experts Only » WordPress Experts: Getting Slug by Single_Cat_Title

WordPress Experts: Getting Slug by Single_Cat_Title

An interesting problem that I came across in a recent project. The client needed a custom post taxonomy set to a gallery of choices on a featured section of their website. First we needed to add custom post types and category images plugins. Iterating through the taxonomy was a cinch but at one point I noticed that a few categories were not linking correctly. This is because we weren’t using the taxonomy’s slug but rather the name. After some searching we found this great little workaround to nail down the proper link. Slugs to the rescue!


 $cat = get_term_by('name', single_cat_title('',false), 'category');

 echo $cat->slug; 

 

http://codex.wordpress.org/Function_Reference/get_term_by

Perfect. Custom post types is a powerful tool but we’ve found a lot of weakness in terms of developing relationships between custom posts. Primarily when using CRUD – developing robust database relationships with WordPress is kind of a pain, not really there yet to replace the other options out there. I think this is because too many plugins and toolsets are gearing toward the idea of “no programming needed”  being a good selling point. Personally, it seems that just making programming easier would be the better option, rather than making a comprehensive alternative to programming. If you don’t know how to program, should you be programming at all?

More Web Design Blog Content

Best Seagate Barracuda Internal Hard Drive 4TB SATA

An Internal Hard Drive With Endless Storage and Impressive Speed. If you require vast data storage while not sacrificing speed, look no further than the Seagate’s Barracuda Internal Hard Drive Model ST4000DM004! With 4 terabytes of reliable storage you can store business documents, videos, pictures, games and movies

Review: PHP Live Chat ★★★★

4 Stars for this chat system from GNTStudio. It’s quite useful and very easy to install. We’re actually planning to use it on our own website we like it so much. They lose one star because we had to modify a bit too much to get things to

Extend Your iPhone or iPad Battery Life

A common problem in todays world – batteries haven’t really kept up with the rest of the tech world and are absolutely the weak link in virtually any modern day tech pack. Things have gotten better over the years. My smartphone lasts about 18 hours depending on usage

Authority + Trust + Relevance = Rankings

Here you go – the magic formula for ranking on Google. Yes, Yahoo and Bing still matter … even though the third most searched term on Bing is “Google”  – people trying to get back to Google, but they’re still relevant. It’s just easier to focus on Google

ADA Compliance

ADA compliance refers to the compliance of websites with the Americans with Disabilities Act, a federal law in the United States that requires businesses and organizations to make their goods and services accessible to people with disabilities. In the context of websites, this means ensuring that individuals with