[WordPress] How to programmatically set a default menu in WordPress.
<?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