How can i adapt the following code to show my custom “Theme Settings” page under “appearence” and NOT under “settings” in the wordpress backend?
add_action('admin_menu', 'theme_options_page'); function theme_options_page() { add_options_page('Theme Settings', 'Theme Settings', 'administrator', __FILE__, 'build_options_page');
Here you can find the full code snippet
using add_submenu_page
add_submenu_page( themes.php, 'Title of Page', 'Theme Options', 'manage_options', 'custom_options', 'custom_function' );
function custom_function()
{
// add your form code here or include a file here
}
for under Appearance use themes.php as parent_slug
or you can also use
using add_theme_page
add_theme_page( 'this is page Title', 'Theme Options', 'manage_options', 'custom_options', 'custom_function' );
for more info please check
you can check
Related
I've been willing to add a submenu to an existing plugin (school project), except that i can see it in the menu, but anytime i open it the page is empty.
Anyone know why it might does this?
static function admin_menu() {
add_menu_page(
_x( 'Foyer', 'plugin name in admin menu', 'foyer' ),
_x( 'Foyer', 'plugin name in admin menu', 'foyer' ),
'edit_posts',
'foyer',
array(),
'dashicons-welcome-view-site',
31
);
add_submenu_page(
'tools.php',
'Foyer Settings', //page title
'Settings', //menu title
'edit_plugins', //capability,
'foyer-settings',//menu slug
'my_custom_submenu_page_content'//callback function
);
}
function my_custom_submenu_page_content() {
echo '<div class="wrap">';
echo '<h2>Page Title</h2>';
echo '</div>';
}
I'm trying to add a custom link as a submenu, below WooCommerce, under "Orders".
I've tried using the following code, but I'm missing something. How do I add a custom link?
add_action('admin_menu', 'register_my_custom_submenu_page');
function register_my_custom_submenu_page() {
add_submenu_page( 'woocommerce', 'My Custom Submenu Page', 'My Custom Submenu Page',
'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' );
}
function my_custom_submenu_page_callback() {
echo '<h3>My Custom Submenu Page</h3>';
}
I used the following code to add a custom link, under WooCommerce:
// Adding custom sub menu
add_action('admin_menu', 'add_custom_link_into_appearnace_menu');
function add_custom_link_into_appearnace_menu() {
global $submenu;
$permalink = 'http://www.cusomtlink.com';
$submenu['woocommerce'][] = array( 'POS Orders', 'manage_options', $permalink );
}
I want to add two additional sub-menu items to my Wordpress Admin menu. The top-level menu I want to hook into is the 'Products' menu created by WooCommerce.
edit.php?post_type=product
The content I want the menu items to show can be accessed by filtering the products by Product Category. E.g.
http://dev3.benefacto.org/wp-admin/edit.php?s&post_type=product&product_cat=manchester
I've come up with a working solution (below) to do this - but it is inelegant because it requires calling a function when I feel like I should be able to simply add something into the 'menu slug' variable perhaps.
Any thoughts much appreciated.
// Hook into the Admin Menu
add_action( 'admin_menu', 'lnz_wp_adminmenu_addproductpages' );
// Add Product Categories
function lnz_wp_adminmenu_addproductpages() {
add_submenu_page( 'edit.php?post_type=product', 'Manchester Charities - Page', 'Manchester Charities- Menu', 'manage_options', 'product_cat_manchester', 'lnz_wp_adminmenu_redirectmanchester' );
add_submenu_page( 'edit.php?post_type=product', 'London Charities - Page', 'London Charities- Menu', 'manage_options', 'product_cat_london', 'lnz_wp_adminmenu_redirectlondon' );
}
// Create Redirects for relevant links
function lnz_wp_adminmenu_redirectmanchester() {
header('Location: http://dev3.benefacto.org/wp-admin/edit.php?s&post_type=product&product_cat=manchester');
exit();
}
function lnz_wp_adminmenu_redirectlondon() {
header('Location: http://dev3.benefacto.org/wp-admin/edit.php?s&post_type=product&product_cat=london');
exit();
}
As far as I know, there's no direct way to achieve this using WP hooks or modifying something like global $submenu...
It can be done with jQuery modifying the href attribute of the submenu items:
add_action( 'admin_menu', function() {
add_submenu_page( 'edit.php?post_type=product', 'Manchester', 'Manchester', 'manage_options', 'cat_manchester', '__return_null' );
add_submenu_page( 'edit.php?post_type=product', 'London', 'London', 'manage_options', 'cat_london', '__return_null' );
});
add_action('admin_footer', function(){
?>
<script>
jQuery(document).ready( function($) {
var admin_url = 'http://dev3.benefacto.org/wp-admin/edit.php';
$('#menu-posts-product').find('a[href*="cat_manchester"]').attr('href',admin_url+'?s&post_type=product&product_cat=manchester');
$('#menu-posts-product').find('a[href*="cat_london"]').attr('href',admin_url+'?s&post_type=product&product_cat=london');
});
</script>
<?php
});
I just making sure that I'm creating the submenu on dashboard correctly.
I'm watching a tutorial on how to create a Setting API on Youtube
The problem is when every I hover on ALLB Option Sitting does pop up with the submenu.
Can anyone help with this quick issue having on WordPress, please explain with detail?
<?php
/*
====================
Admin Page
====================
*/
function allb_admin_page() {
//Generate A Legacy Left Behind Admin Page
add_menu_page( ' ALLB Theme Options', 'ALLB Options', 'manage_options', 'a_legacy_left_behind', 'allb_theme_create_page', 'dashicons-admin-customizer', 110);
//Generate A Legacy Left Behind Admin Sub Page
add_submenu_page('allb_theme', 'ALLB Theme Options', 'Setting', 'manage_options', 'a_legacy_left_behind', 'allb_theme_settings_page');
}
add_action('admin_menu', 'allb_admin_page');
function allb_theme_create_page() {
// genration of our admin page
}
function allb_theme_settings_page() {
// genration of our admin page
}
Here is the answer..
Just copy and past this code in your theme's functions.php file..
Would you please try it once ?
add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' );
add_submenu_page('my-menu', 'Submenu Page Title', 'Whatever You Want', 'manage_options', 'my-menu' );
add_submenu_page('my-menu', 'Submenu Page Title2', 'Whatever You Want2', 'manage_options', 'my-menu2' );
}
I hope its helpful for you..
Hope this will solve your issue
function allb_admin_page() {
//Generate A Legacy Left Behind Admin Page
add_menu_page( 'ALLB Theme Options', 'ALLB Options', 'manage_options', 'a_legacy_left_behind', 'allb_theme_create_page');
//Generate A Legacy Left Behind Admin Sub Page
add_submenu_page('a_legacy_left_behind', 'ALLB Theme Options', 'Setting', 'manage_options', 'a_legacy_left_behind_sub', 'allb_theme_settings_page');
}
I am using the add_menu_page function on WordPress; this is the code;
function my_admin_menu() {
add_menu_page( 'My Top Level Menu Example', 'Top Level Menu',
'manage_options', 'example.php', 'myplguin_admin_page', 'dashicons-tickets', 6 );
}
example.php
function display_text() {
echo 'Welcome to my page';
}
I get the menu in the dashboard, but the issue has content on the page. I can click the top-level option page from the dashboard, but once I do that, I get an empty page where it should say 'Welcome To My page'. Any ideas on how to get my content to show?
You were using a wrong function name that is why it was showing a blank page.
function my_admin_menu() {
add_menu_page( 'My Top Level Menu Example', 'Top Level Menu', 'manage_options', 'example.php', 'myplguin_admin_page', 'dashicons-tickets', 6 );
}
function myplguin_admin_page(){
echo 'Welcome to admin page';
}
You can try this code, because i use this and work
add_menu_page(
'Import Resi', // Page Title
'Import Resi', // Menu Title
'manage_options', // Capabiliy
'import_php/index.php', // Menu_slug
'', // function
'', // icon_url
6 // position
);
add_menu_page(
'Admin Cek', // Page Title
'Admin Cek', // Menu Title
'manage_options', // Capabiliy
'admin_cek/index.php', // Menu_slug
'', // function
'', // icon_url
7 // position
);
you need to use the correct function name and a more appropriate identifier than example.php. you can require your file from the called function
function my_admin_menu() {
add_menu_page( 'My Top Level Menu Example', 'Top Level Menu', 'manage_options', 'example', 'display_text', 'need a uri to your image here!!', 6 );
}
function display_text(){
require_once 'pathtofile.php'; //--> make sure you read up on paths and require to find your file.
}