[ad_1]
Thread Starter
Leo.Lin
(@bi1012037)
I modified 『Simple_Posts_Table.php』 and it worked successfully
public function get_table( $args ) {
...
// Separate sticky and non-sticky posts
$sticky_posts = [];
$non_sticky_posts = [];
foreach ( $all_posts as $post ) {
if ( is_sticky( $post->ID ) ) {
$sticky_posts[] = $post;
} else {
$non_sticky_posts[] = $post;
}
}
// Sort the non-sticky posts by date (most recent first)
usort( $non_sticky_posts, function( $a, $b ) {
return strtotime( $b->post_date ) - strtotime( $a->post_date );
});
// Merge sticky posts and non-sticky posts
$all_posts = array_merge( $sticky_posts, $non_sticky_posts );
...
}
-
This reply was modified 40 seconds ago by
Leo.Lin.
