Trying to add CPT to menu automatically

This code is pulling in custom posts automatically and setting menu order as it does within the function, so trying to change the order in the menu editor will likely cause an error.

To change the order change this line:

 foreach ( get_posts( 'post_type=cpt-post-type-here&numberposts=-1' ) as $post ) {

to

 foreach ( get_posts( 'post_type=cpt-post-type-here&numberposts=-1&order=ASC' ) as $post ) {

I’ve added an ‘order’ statement to sort ASC.

I prefer arrays because they are easier for me to read. You could rewrite your query to this:

$args = array(
    'post_type'=> 'your-custom-post-type',
    'numberposts' => -1,
    'order'    => 'ASC'
);

foreach ( get_posts( $args ) as $post ) {

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino