Reputation: 742
to avoid installing my menu in each pages (sidebar.php, index.php, category.php, etc.), i create a template part (a php.file) for my menu, for example :
<?php
/**
* The template for displaying menu in Twenty Eleven Child Theme
*
* @package WordPress
* @subpackage My Twenty_Eleven Child Theme
* @since My Twenty Eleven Child Theme 1.0
*/
?>
<div id="menu">
<ul>
<li>
<a href="http://www.mylink1.com/">home</a>
</li>
<li>
<a href="http://www.mylink2.com/">about</a>
</li>
<li>
<a href="http://www.mylink3.com/">contact</a>
</li>
</ul>
</div>
Then i install the <?php get_menu(); ?>
after the <div id="primary">
in each page where i want to show the menu...
I guess i must also make some codes in the function.php (register the menu), how should i do ??? What else should i do still ?
Please note that i do not know much about php !
Thanks for your help in advance !
Upvotes: 0
Views: 39
Reputation: 968
Thought I would push my answer out of the comments:
function get_menu(){
$menu = "<div class='menu'><ul><li><a href='/link'>Link</a></li></ul></div>";
return $menu;
}
Then on the page:
<?php $get_menu = get_menu(); echo $get_menu; ?>
Unless you wanted to register your get_menu
as a global variable in that case you would just need to <?php echo get_menu(); ?>
Upvotes: 1