if (is_admin())
{
add_action('admin_menu', 'user_menu');
}
function user_menu()
{
add_menu_page('Pesananku', 'Pesananku', 'subscriber', 'userslug',
'user_funct',get_template_directory_uri().'/img/favicon.ico',22);
}
function user_funct()
{
?>
<h2 class="nav-tab-wrapper">
<a href="#tab1" class="nav-tab">Tab #1</a>
<a href="#tab2" class="nav-tab nav-tab-active">Tab #2</a>
<a href="#tab3" class="nav-tab">Tab #3</a>
</h2>
<div id="tab1"><!--content tab1--></div>
<div id="tab2"><!--content tab2--></div>
<div id="tab3"><!--content tab3--></div>
<?php
}
i want 'user_funct()' create tab with styling wordpress like this
http://postimg.org/image/h3nttjhof/
how to create different content with link tab menu
Thanks
To get a quick grasp of the tabs we'll be creating, go to Appearance/Themes in the WordPress admin area. You will find two tabs there: “Manage Themes” and “Install Themes.” When you click on one, the content changes and the tab's title is highlighted.
Here is how you can go about it;
First, you need to create a function that create the structure depending on the current tab selected:
function page_tabs( $current = 'first' ) {
$tabs = array(
'first' => __( 'First tab', 'plugin-textdomain' ),
'second' => __( 'Second tab', 'plugin-textdomain' )
);
$html = '<h2 class="nav-tab-wrapper">';
foreach( $tabs as $tab => $name ){
$class = ( $tab == $current ) ? 'nav-tab-active' : '';
$html .= '<a class="nav-tab ' . $class . '" href="?page=ipl_dbx_import_export&tab=' . $tab . '">' . $name . '</a>';
}
$html .= '</h2>';
echo $html;
}
Then in the callback function called to display the page which will contain the tabs, you need to use this function like that:
<?php
// Code displayed before the tabs (outside)
// Tabs
$tab = ( ! empty( $_GET['tab'] ) ) ? esc_attr( $_GET['tab'] ) : 'first';
page_tabs( $tab );
if ( $tab == 'first' ) {
// add the code you want to be displayed in the first tab
}
else {
// add the code you want to be displayed in the second tab
}
// Code after the tabs (outside)
?>
Also then you call the page, you can add a GET value called tab
corresponding to the tab you want to display, e.g.:
admin.php?page=my_plugin_page_slug&tab=second
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With