-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort folders by most recent update of contained doc #688
Comments
Modified date of the folder object sounds good to me. Thanks for looking into this! |
I have read this and #689 and it relates to what a client of mine is requesting of me (and quickly): the ability to set default sort order per folder. This would include an option of menu order sorting. Please let me know if this is possible and whether this should be requested as a standalone feature request. |
Hi @pgrafix Sure, it would be possible to set the default sort order for each specific folder (only to be used when viewing a single folder--I don't think it would make sense to change the sort order if you were looking at three expanded folders for instance.) by attaching meta to the post that defines the folder and then using that meta to change the order in the query if no sort order has been specified. It's not high on my list to implement, but I do believe that it would be possible. |
@dcavins Thank you for the response, David. In the meantime would it possible to get a snippet that would allow us to manually target a folder? |
I think I am close, but perhaps I am targeting the wrong hook:
As I said, I just need to target a single folder for default ordering of by creation date instead of title. Any help would be greatly appreciated. |
@pgrafix It looks like you're probably targeting the correct hook, but your references to add_filter(
'bp_after_bp_docs_has_docs_parse_args',
function ( $args ) {
$current_folder_id = bp_docs_get_current_folder_id();
$folder_id_to_target = 12345; // Replace with your folder ID
if ( $current_folder_id !== $folder_id_to_target ) {
return $args;
}
if ( ! empty( $_GET['orderby'] ) ) {
return $args;
}
$args['orderby'] = 'created';
$args['order'] = 'DESC';
return $args;
}
); |
I appreciate your response @boonebgorges - I knew I was missing something. Thanks again for all of your assistance. UPDATE:
In fact, we seem to be encountering a default orderby of Last Edited for all folders even though code has not been set to make it so and the default orderby for folders is by title based on the code in addon-folders.php. Where is orderby stored when not empty? Clearing cache, cookies and site-settings in the browser doesn't seem to affect this [return to default of by title]. |
I think this is a good idea: https://wordpress.org/support/topic/re-ordering-folders/
It could be accomplished by changing the modified date of the enclosing folder(s) when a doc is updated or by adding "modified" meta to the folder. Boone, do you have a preference? I guess I'm leaning toward changing the modified date because we're not using it for anything.
The text was updated successfully, but these errors were encountered: