Skip to content

Instantly share code, notes, and snippets.

@LittleCoding
Last active January 30, 2018 17:01
Show Gist options
  • Save LittleCoding/66ce9109d79810311178786215ea7f5e to your computer and use it in GitHub Desktop.
Save LittleCoding/66ce9109d79810311178786215ea7f5e to your computer and use it in GitHub Desktop.
Change default "+ New" content post type to page in WordPress administration menu bar
<?php
/**
* code to be placed in theme functions.php
* add_filter priority of 70 or greater.
*/
if ( ! function_exists( 'mytheme_admin_bar_menu' ) ) {
function mytheme_admin_bar_menu( $wp_admin_bar ) {
$new_content = (object) $wp_admin_bar->get_node( 'new-content' );
if ( ! empty( $new_content->href ) ) {
$new_content->href = admin_url( 'post-new.php?post_type=page' );
$wp_admin_bar->add_node( $new_content );
}
}
add_filter( 'admin_bar_menu', 'mytheme_admin_bar_menu', 70 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment