How to add custom page in Wordpress Admin

If you are want to add new Functionality or other user data management in your wordpress theme ?? You can  Create a new page in wordpress admin Section.



For That First of all You have to add a New Menu in Wordpress Dashboard Menu.

For that You have to add a Code in your theme Function.php file

Add code in Function.php File




add_action('admin_menu', 'register_custom_menu_page');

function register_custom_menu_page() {
   add_menu_page('custom menu title', 'custom content Type', 'add_users', 'customcontent.php', '',   plugins_url('myplugin/images/icon.png'), 6);
}


Here the Link of the added menu is customcontent.php so we have to create a new file in
wp-admin folder with name customcontent.php .

In this file you can  add Your Custom PHP Code , According to your function Requirements.

Add Following Code into Customcontent.php File 


<?php
/**
 * Custom Administration Screen.
 *
 * @package WordPress
 * @subpackage Administration
*/

/** WordPress Administration Bootstrap */
require_once('./admin.php');

$title = __('Custom Content');

get_current_screen()->add_help_tab( array(
'id'      => 'press-this',
'title'   =>  
__('Press This'),
'content' => '',
) );
get_current_screen()->add_help_tab(  
array(
'id'      => 'converter',
'title'   => __('Categories and Tags Converter'),
'content' =>  '',
) );

get_current_screen()->set_help_sidebar(
 
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a  
href="http://codex.wordpress.org/Tools_Screen" target="_blank">Documentation on Tools</a>') .  
'</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') .  
'</p>'
);

require_once('./admin-header.php');

?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>

<?php if ( current_user_can('edit_posts') ) : ?>
<div  
class="to<p><?php _e('Press This is a bookmarklet: a little app that runs in your browser and lets you  
grab bits of the web.');?></p>

<p><?php _e(''); ?></p>
<p class="description"><?php  
_e('') ?></p><div class="pressthis-code" style="display:none;"><p><textarea rows="5" cols="120"  
readonly="readonly"><?php echo htmlspecialchars( get_shortcut_link() ); ?></textarea></p>
 
</div>
</div>
<?php
endif;

if ( current_user_can( 'import' ) ) :
$cats = get_taxonomy('category');
$tags = get_taxonomy('post_tag');
if ( current_user_can($cats->cap->manage_terms) ||  
current_user_can($tags->cap->manage_terms) ) : ?>
<div class="tool-box">    <p><?php printf( __(''),  
'import.php' ); ?></p>
</div>
<?php
endif;
endif;

do_action( 'tool_box' );
?>
</div>
<?php // Custom Code Starts Here ?>

This is Custom Content area

<?php // Custom Code Starts Here ?>
<?php
include('./admin-footer.php');


You can add a php code or content as your requiremrnts in this file...

Now You can add a new menu in Wordpress dashboard and Set your code that you want to run in your newly created file inside the folder wp-admin.

That's it..Enjoy Coading.

Comments