Ability to Order files in wpdm_tree [WPDM Extended Shortcodes]

Viewing 8 posts - 1 through 8 (of 8 total)
#42802

brunzino
Member

Currently the wpdm_tree shortcode displays files within the folders ordered by ‘post_date’. I wanted to order them by ‘title’ instead so I’ve updated the WPDM Extended Shortcodes plugin file https://wordpress.org/support/topic/how-to-order-documents-within-wpdm_tree-wpdm-extended-shortcodes-workaround?replies=1#post-8161730

It looks simple enough to add that parameter to the shortcode and send with the AJAX request. I will try to make the updates this week.

Thanks a lot!

#42809

brunzino
Member

Included is the updated file, with a git-diff of the original plugin file and the updated file.

This update allows the wpdm_tree shortcode to accept order_by and order parameters, in accordance with the capabilities of WP_QUERY()

[wpdm-extended-shortcodes.php]
It first accepts the parameters and assigns the current default values (order_by = ID, order = DESC) if not defined. (~ line 21)
Sends these parameters in the AJAX request. (~line 30)
Accepts the AJAX parameters (~line 410) and applies them to the WP_QUERY() params (~line 420)

Example:
[wpdm_tree category="policy-documents" download_link="1" order_by="title" order="ASC" ]

Thanks again and I hope this helps!

#42811

brunzino
Member

Doesn’t accept php files, here’s a .tar

#42814

brunzino
Member

Test Cases:

// No values
[wpdm_tree category=”agency-policy” download_link=”1″]

// Valid values
[wpdm_tree category=”agency-policy” download_link=”1″ order_by=”title” order=”ASC” ]

// Invalid Values
[wpdm_tree category=”agency-policy” download_link=”1″ order_by=”SOMETHING_IMPOSSIBLE” order=”NOT_ASC_OR_DESC” ]

#42815

brunzino
Member

The default value for order_by should be ‘date’ NOT ‘ID’ . This is the current default for WP_QUERY and should persist.

#42816

brunzino
Member

Also, $order should probably be strtoupper($order) as WP_QUERY only accepts upper case for that option.

#67504

Nathan Lyle
Member

While the files appear to order as expected, child categories don’t… or is there a separate way to indicate how those should be sorted? On my page I have the main category “Council Meeting Minutes” and then sub categories for “2018”, “2017”, etc. The files sort by date as hoped, but not the child categories.

This is the shortcode I’m using: [wpdm_tree download_link=1 category=”city-council-meeting-minutes” orderby=”date”]

#67520

Nathan Lyle
Member

I installed https://wordpress.org/plugins/taxonomy-terms-order/ and was able to get the category order the way I wanted.

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Ability to Order files in wpdm_tree [WPDM Extended Shortcodes]’ is closed to new replies.