Skip to content
💸 Introductory Pricing: Save 50% on bundle plans for your first year Get deal

Order galleries in administration by date

When viewing your client photo galleries in your WordPress administration, you can sort the galleries by date. Click the "Date" column header in the gallery list view and galleries will be displayed oldest to newest. Click again and they will be sorted newest to oldest.

If you would like to have galleries default to be newest to oldest, use this custom code:

add_action('pre_get_posts', 'sort_sunshine_gallery_by_date');
function sort_sunshine_gallery_by_date($query) {
if( ! is_admin() || ! $query->is_main_query() ) {
return;
}

if ( 'sunshine-gallery' === $query->get('post_type') ) {
$query->set('orderby', 'date');
$query->set('order', 'DESC');
}
}

Learn how to add this custom code to your WordPress website

Still need help?

If you have not yet found your answer in the documentation articles, please contact support