Quand vous affichez une page listant du contenu privé (par ex. le tableau de bord, mes fichiers, mes pages, mes conversations), WP Customer Area effectue une requête pour récupérer tous les contenus privés assignés à l’utilisateur courant.
Dans certains cas, vous pourriez avoir besoin de modifier ces requêtes – pour changer par exemple, l’ordre d’affichage. Il vous suffit d’inclure ce bout de code dans functions.php ou cuar-functions.php.
Disons que vous souhaitez organiser vos fichiers dans des catégories mais que le dernier fichier mis à jour s’affiche en tête de liste.
function cuar_custom_sorting_order( $args ) { $new_args = $args; // The next line says that the sort order will be by the date of the last modification // You could also sort by any field of the WordPress post table, like 'title' $new_args['orderby'] = 'modified'; // This line says that we want to sort by descending order (opposite of 'ASC') $new_args['order'] = 'DESC'; return $new_args; } // You can change the page slug to another one, for instance 'customer-private-pages' or 'customer-conversations' $page_slug = 'customer-private-files'; // Uncomment the add_filter line you need, depending on where you want to change the sorting order // 1. Change the order on the "My files" page (for any display mode) // add_filter( 'cuar/core/page/query-args?slug=' . $page_slug, 'cuar_custom_sorting_order' ); // 2. Change the order on the "My files" page (not when we are showing date archives or category archives) // add_filter( 'cuar/core/page/query-args?slug=' . $page_slug . '&display-mode=default', 'cuar_custom_sorting_order' ); // 3. Change the order on the "My files" page (when showing date archives) // add_filter( 'cuar/core/page/query-args?slug=' . $page_slug . '&display-mode=date_archive', 'cuar_custom_sorting_order' ); // 4. Change the order on the "My files" page (when showing category archives) // add_filter( 'cuar/core/page/query-args?slug=' . $page_slug . '&display-mode=category_archive', 'cuar_custom_sorting_order' ); // 5. Change the order on the "My files" page (when showing author archives) // add_filter( 'cuar/core/page/query-args?slug=' . $page_slug . '&display-mode=author_archive', 'cuar_custom_sorting_order' ); // 6. Change the order on the "Dashboard" page // add_filter( 'cuar/core/dashboard/block-query-args?slug=' . $page_slug, 'cuar_custom_sorting_order' );