-
-
Save tommcfarlin/a049b1532141a126d158 to your computer and use it in GitHub Desktop.
[WordPress] How to programmatically set a default menu in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Provides a default menu featuring the 'Home' link, if not other menu has been provided. | |
* | |
* @package Acme | |
* @subpackage inc | |
* @version 1.0.0 | |
* @since 1.0.0 | |
*/ | |
function acme_default_menu() { | |
$html = '<ul id="acme-default-menu">'; | |
$html .= '<li class="menu-item menu-item-type-post_type menu-item-object-page">'; | |
$html .= '<a href="' . esc_url( home_url() ) . '" title="' . __( 'Home', 'acme' ) . '">'; | |
$html .= __( 'Home', 'acme' ); | |
$html .= '</a>'; | |
$html .= '</li>'; | |
$html .= '</ul>'; | |
echo $html; | |
} // end acme_default_menu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment