Quite often I’ll see users requesting to output a list of categories within Easy Digital Downloads and link through to each one. Although there’s a widget provided by EDD to do this, if you have many categories, simply listing them out in the sidebar isn’t sufficient.

If you start with something simple, you can gradually build the HTML and style it accordingly with CSS to match your site’s design.

Categories in EDD are actually WordPress terms, which I think confuses a lot of people. WordPress categories themselves are actually a taxonomy themselves. The taxonomy that each term in EDD belongs to is called download_category. We’ll need to make use of WordPress’ get_terms() and get_term_link() functions to achieve what we’re after.

Simply copy and paste the following function into your child theme’s functions.php or a custom plugin you have created:

Then, you can run the function where you’d like it to display, such as a custom page template:

<?php echo sumobi_list_edd_terms(); ?>

17 comments

  1. This is really useful. Thank you! Is it possible to amend the example above so that certain categories (or parent categories specifically) can be removed from the list?

      1. Hi,

        I’ve use the codes in my child theme’s functions.php and created a new page called categories.
        After wich i used the following codes in in the text section but the page doesnt seem to list out the categories.

        Perhaps i dont quite understand the function. Appreciate your assistance.

  2. I’ve this error : “Fatal error: Call to undefined function sumobi_list_edd_terms() in www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(373) : eval()’d code on line 1”

  3. It’s working but I have a question, is it possible to add a link for “all” products, main store page?

  4. Hi Sumobi,

    Your code ends with the wrong closing tag, wouldn’t that be confusing for people familiar with code. Or maybe I’m the one getting it wrong

    <?php }

    1. Sorry if you find that confusing, but there’s nothing wrong with it. That’s how you can show HTML code within a PHP function, without having to echo every line.

  5. Would work if I pasted it into a child stylesheet?
    I’m looking to create a page with a grid of categories.
    I’m a little lost on what I can actually paste into a page like a shortcode for each category rather than a list of items in a category, Which I can do.
    Any advice?

    1. Sorry no it would not work because it’s not CSS styling. You can however put it in your child theme’s functions.php or custom plugin at outlined above. The code above outputs each of your categories so you can use this to create your grid and then place it on your download category page or whichever you’re using in your theme.

      1. Thanks. Makes sense. I think the Page_templates material on the wordpress codex seems to be a bit of a primer. I have successfully made a new page template though I need to get the child theme functioning properly. So I’ll head off with that and hopefully this will work.

  6. Hi,

    I placed the codes in my child theme’s functions.php and then placed in a fresh page but it doesnt seem to do anything.

    Appreciate any help i could get

  7. Is there a way to make it show like some sort of breadcrumb?
    E.g. Plugins > php scripts > countdown

Comments are closed.