I work on a project in which I want to remove +New link in WordPress admin bar. Actuly i want to replace 'new' to 'ADD Deal'. Is there any function in WP with this we can replace this text or how can I do this.
2 Answers
I think what you are asking is changing the text +NEW to ADD Deal.
This code is adjusted like that.
add_action( 'admin_bar_menu', 'change_new_post_name', 999 );
function change_new_post_name ( $wp_admin_bar ) {
//Removing +New
$wp_admin_bar->remove_node( 'new-content' );
//hyperlink for the new link. This can be anything. Currently it's default.
$link = get_bloginfo('url').'/wp-admin/post-new.php';
//Parameters to create a new node
$args = array(
'id' => 'new-content', //re-creating the +New
'title' => 'ADD Deal', //Giving it a different title
'href' => "$link" // Above created link
);
$wp_admin_bar->add_node( $args );
}
For removing +New from admin menu bar and adding a new node to the admin bar, you can use the following code.
add_action( 'admin_bar_menu', 'wpse135424_remove_newpost', 999 );
function wpse135424_remove_newpost ( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'new-content' );
$args = array(
'id' => 'your_page',
'title' => 'Your Title',
'href' => 'Your Url'
);
$wp_admin_bar->add_node( $args );
}
Please check the codex for adding node.