Solution when get_terms fails to retrieve

In WordPress, you can use the get_terms function to retrieve items from a taxonomy. However, if for some reason this does not work, try the following solution

Set hide_empty => false as an argument. This will allow you to retrieve terms that do not have a post associated with them. The specific code is as follows

$args = array( 
 'hide_empty' => false, 
); 
$terms = get_terms( $args ); 

This method should give you the expected results.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top