• Hi, I’ve been racking my brain and can’t figure out how to get this to work. I created some custom menu links that display two categories together For example – Collections & Fabric the link i’m using is https://www.tdfall.com/category/collections+category.

    I have been using the_category() to display the title on the page, but now it shows both categories in the title “Collections Fabric” How can I make it show up as only Fabric in the title?

    If anyone can help! that would be so great! Thank you!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Hook ‘the_category’ filter to manipulate the HTML output just before it is echoed out. Use PHP string functions to find the first part of the category title and replace that portion with an empty string. For maximum flexibility in identifying the first part of a title, preg_replace() works very well by using a regexp to do the matching.

Viewing 1 replies (of 1 total)
  • The topic ‘Excluding a category title with multiple categories’ is closed to new replies.