Wordpress: Default sorting by column of custom post type : <p>I have a custom post type called Contact, with custom fields like first name, surname, telephone number etc.</p>

<p>In the admin section they're sorted chronologically I think, but I need them to be sorted by surname by default.</p>

<p>I've read all the other solutions on here and none of them work, including:</p>

<pre><code>function set_post_order_in_admin( $wp_query ) {
global $pagenow;
  if ( is_admin() &amp;&amp; 'edit.php' == $pagenow &amp;&amp; !isset($_GET['orderby'])) {
    $wp_query-&gt;set( 'orderby', 'surname' );
    $wp_query-&gt;set( 'order', 'ASC' );
  }
}
add_filter('pre_get_posts', 'set_post_order_in_admin' );
</code></pre>

<p>But whatever field I try to sort by, nothing changes, except toggling ASC/DESC seems to change to reverse chronological ordering.</p>

<p>What am I doing wrong?</p>
