title: Adding Admin Menu Separators in WordPress
body: <p>I am trying to create an admin menu separator that allows you to put them in with code. This is the function:</p>
  <pre class="lang-php prettyprint-override"><code>function add_admin_menu_separator($position) {
    global $menu;
    $index = 0;
    foreach($menu as $offset =&gt; $section) {
      if (substr($section[2],0,9)=='separator')
      $index++;
      if ($offset&gt;=$position) {
        $menu[$position] = array('','read',&quot;separator{$index}&quot;,'','wp-menu-separator');
        break;
      }
    }
    ksort( $menu );
  }
  </code></pre>
  <p>The add action bit is below</p>
  <pre class="lang-php prettyprint-override"><code>add_action('admin_init','admin_menu_separator');
      
  function admin_menu_separator() {
    add_admin_menu_separator(220);
  }
  </code></pre>
  <p>It works okay but it produces the following errors in WordPress when rearranging menus:</p>
  <pre><code>&gt; Warning: Invalid argument supplied for foreach() in /home/user/public_html/wp-creation.com/wp-content/themes/liquid_theme_0.4_licensed/functions.php on line 174
      
  &gt; Warning: ksort() expects parameter 1 to be array, null given in /home/user/public_html/wp-creation.com/wp-content/themes/liquid_theme_0.4_licensed/functions.php on line 182
  </code></pre>