Create a list of all categories

Viewing 2 posts - 1 through 2 (of 2 total)
#86600

Hi everyone,

I have several files I want to make available to my users, like users manual…
The files are divided between categories, that correspond on my side to products.
What I would like to do is to create a single page with a dropdown list containing every category I have, and to display the downloadable files from the selected category.

I have no issue with the list/display selected elements part, but I have no idea how I can gather my files categories and IDs in the first place.
Is there a way to get every downloadable file category and ID?

Is there already a function like wordpress’ get_categories();?
Thank you if you know how I can make this work.

Florian

#86758

Shahjada
Keymaster

Looks like you will need:

WPDM Directory Add-on


Demo:
https://demo.wpdownloadmanager.com/wpdmpro/archive-page-sidebar/

However, if you are going to code it by yourself, wpdm is a custom post type ( wpdmpro ), and categories are taxonomy ( wpdmcategroy )
So, you can use get_terms function ( https://developer.wordpress.org/reference/functions/get_terms/ ) where taxonomy = wpdmcategroy.
For example:

$download_categories = get_terms( array(
    'taxonomy' ► 'wpdmcategroy',
    'hide_empty' ► false,
) );
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Create a list of all categories’ is closed to new replies.