Advertisement
michaellevelup

CPT display order

Apr 14th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. function custom_agenda_order( $orderby ) {
  2.     global $wpdb;
  3.    
  4.     // Check if the query is for an archive
  5.     if ( is_archive() && get_query_var("post_type") == "my_custom_post_type" ) {
  6.         // Query was for archive, then set order
  7.         return "$wpdb->posts.post_date ASC";
  8.     }
  9.    
  10.     return $orderby;
  11. }
  12.  
  13. add_filter( 'posts_orderby' , 'custom_agenda_order' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement