In some cases you may wish to display downloads from a particular category on a WordPress post or page. Instead of needing an individual shortcode for each download, you can use this documentation to help you display all the items you have placed in a category on a page. You can also place multiple shortcodes on a page if you need to show more than one category.
Categorizing Your Downloads
Before using a shortcode to display downloads from a particular category you will need to ensure you have categorized your downloads first.
To place a download into a category you will need to complete the following:
- Click on the ‘Downloads’ menu.
- Select the download(s) you would like to place in a category.
- On the right-hand side of the ‘Edit Download’ page you will see a section titled ‘Download Categories’.
- Select the category you would like to place your download in. Alternatively, create a new category for your download.
- Place similar downloads within the same category.
- Ensure you ‘Update’ any changes you have made.
Displaying all Downloads from a Particular Category on a Post/Page
Locating Category Slug or ID
To display all the downloads that you have placed in a particular category, you will first need to locate the category slug/ID.
- Click on the ‘Downloads’ menu.
- Go to the the ‘Categories’ menu. You can see all the download categories you have created here. This is where you will find the slug of the category.
Displaying Downloads on a Post/Page
Now that you have located the category slug for the downloads that you wish to show, you can use the following shortcode on any WordPress post or page. Using this shortcode will show all of the downloads that have been placed in the category.
[sdm_show_dl_from_category category_slug="test-download-category" fancy="1"]
The category slug in the above example is test-download-category. You will need to replace this with the slug of the download category you wish to display. Ensure you paste and edit this shortcode in the text editor.
Example: Listing Downloads from a Particular Category
Using the above shortcode, all of your downloads from the specified category will be listed one after another like the example shown below:
Sorting the Display of Downloads from a Particular Category
You can use the “orderby” and “order” parameters to customize the sorting of the download items. These shortcodes enable you to decide how your downloads are listed on a post or page.
Sorting Downloads by Date
Here is an example shortcode that will sort the downloads by post date and in descending order:
[sdm_show_dl_from_category category_slug="test-download-category" fancy="1" orderby="date" order="desc"]
Sorting Downloads by Title
Here is an example shortcode that will sort the downloads by post title and in ascending order:
[sdm_show_dl_from_category category_slug="test-download-category" fancy="1" orderby="title" order="asc"]
Adding Pagination to Category Download Items Display
You can use the “pagination” parameter to paginate the category items display. This allows you to decide how many items are displayed per page.
Here is an example shortcode that will paginate the display and show 20 download items per page:
[sdm_show_dl_from_category category_slug="test-download-category" fancy="1" pagination="20"]
You can change the number “20” in the above shortcode to a number of your choosing. For example, by replacing it with “2“, only 2 downloads will be shown per page (see image below).
Showing Download Items from Multiple Categories
You can specify multiple category slugs or IDs in the shortcode.
For example: the following shortcode will display all downloads that belong to category1 or category2
[sdm_show_dl_from_category category_slug="category1, category2" fancy="1"]
For example, the following shortcode will display all downloads that belong to category ID 5 or category ID 6
[sdm_show_dl_from_category category_slug="5, 6" fancy="1"]
Center Align the Pagination
Use the following CSS code to make the pagination links have a center alignment:
.sdm_pagination { text-align: center; }
Default Category Listing Page
The plugin also has a default category page where all the downloads of a particular category is listed. Check this tutorial to see how this default category listing works.