Thread Starter
Bloke
(@bloke)
I got it to run the first function. Now it won’t display the sub menu button.
`
add_action(‘admin_menu’, ‘myLiterature_menu’);
function myLiterature_menu() {
add_menu_page(‘addLiterature’, ‘Literature’, 1, ‘manage_options’,’addLiterature’);
add_submenu_page(‘addLiterature’, ‘Literature’, 1,’manage_options’,’editLiterature’);
}
function addLiterature() {
echo “<p>This is the page to edit content</p>”;
}
function editLiterature() {
echo “<p>Edit page</p>”;
}’
You closed your code with an apostrophe instead of a backtick, so the forum’s parser might have corrupted some of your code. But your parameters for the two menu page functions appear to be wrong. Check the order, number, and type of parameters carefully, it’s easy to get them mixed up or forgotten. And the parameters are not exactly the same for each function, adding to the confusion. For example, the capability parameter is fourth in one and third in the other.
Thread Starter
Bloke
(@bloke)
Tried this and still can’t get the sub menu to appear.
add_action('admin_menu', 'myLiterature_menu');
function myLiterature_menu() {
add_menu_page('addLiterature', 'Literature', 10,'manage_options', 'add-literature','addLiterature');
add_submenu_page('addLiterature', 'EditLiterature' ,10,'manage_options','edit-literature', 'editLiterature');
}
function addLiterature() {
global $title;
?>
<div class="wrap">
<h2><?php echo $title;?></h2>
... Functionality for adding content will go here ...
<div id="icon-edit-pages" class="icon32"></div>
</div><?php
}?>
<?php function editLiterature() {
global $title;
?>
<div class="wrap">
<h2><?php echo $title;?></h2>
... Functionality for edit content will go here ...
</div><?php
}?>
Thread Starter
Bloke
(@bloke)
I finally got it to work after I figured the slug line and the order of things. Also it would say I didn’t have permissions and I would have to sign out and back in to test it each time I changed the code.
add_action('admin_menu', 'myLiterature_menu');
function myLiterature_menu() {
add_menu_page('Literature','Literature',10,'get-literature','addLiterature');
add_submenu_page('get-literature','Literature','Edit Literature',10,'edit-literature','editLiterature');
}
function addLiterature() {
global $title;
?>
<div class="wrap">
<h2><?php echo $title;?></h2>
Functionality for adding content will go here ...
<div id="icon-edit-pages" class="icon32"></div>
</div><?php
}?>
<?php function editLiterature() {
global $title;
?>
<div class="wrap">
<h2><?php echo $title;?></h2>
Functionality for editing content will go here ...
</div><?php
}?>