Quick tip: get_terms with all terms

The get_terms WordPress function is listing all your terms for a given taxonomy (or taxonomies).

However, the default callback returns only the terms with entries. Therefore your empty terms won’t be visible unless you use the hide_empty parameter with a false value, like this:

[php]

$product_terms = get_terms( ‘product’, array( ‘hide_empty’ => false ) );

[/php]

Passing the hide_empty parameter would fetch the empty terms from your product category as well.


Mario Peshev is a serial martech entrepreneur, global business advisor, angel investor, and author, famous for launching a top 20 enterprise WordPress consultancy and authoring the modern startup formation book, “MBA Disrupted.”

His digital footprint includes 25 years of creating and scaling technical solutions, building and growing digital teams, starting and growing companies from zero to seven figures, acquiring and selling assets and businesses, and investing in global startups like beehiiv, doola, the Stacked Marketer, Alcatraz, SeedBlink.

Peshev spent over 10,000 hours in consulting and training activities for organizations like VMware, SAP, Software AG, CERN, Saudi Aramco since 2006. His books and guides are references in over 30 universities in North America, Europe, and Asia.


Follow Mario on social:

Latest Editions:

Browse by Category

Latest Answers: