Thread Starter
oudrib
(@oudrib)
Hi @spgandhi,
Thank you for your fast response i just started coding with this :
if ( ! function_exists(‘regenerate_menu’)){
function regenerate_menu( $post ) {
remove_action(‘edit_post’, ‘regenerate_menu’);
remove_action(‘save_post’, ‘regenerate_menu’);
remove_action(‘publish_post’, ‘regenerate_menu’);
remove_action(‘edit_page_form’, ‘regenerate_menu’);
add_action(‘trash_post’, ‘regenerate_menu’);
$list_pages = wp_list_pages($args);
foreach ($list_pages as $key => $value) {
$hash_link = mb_convert_encoding(str_replace(‘ ‘, ”, $post->post_title), ‘EUC-JP’, ‘auto’);
}
if( home_url( ‘/#’. $hash_link) == $link->url ){
wp_update_nav_menu_item($themenu->term_id, $link->ID, array(
‘menu-item-title’ => __( get_the_title() ),
‘menu-item-url’ => home_url( ‘/#’. $hash_link ),
‘menu-item-status’ => ‘publish’));
$flag = $key;
}
}
add_action(‘edit_post’, ‘regenerate_menu’);
add_action(‘save_post’, ‘regenerate_menu’);
add_action(‘publish_post’, ‘regenerate_menu’);
add_action(‘edit_page_form’, ‘regenerate_menu’);
add_action(‘trash_post’, ‘regenerate_menu’);
}
Why do you want a custom menu? The WP nav menu does everything you describe, why not use that?
Thread Starter
oudrib
(@oudrib)
Hi @bcworkz,
thank you for your response, i want to create custom items in the menu (home_url/#about) and list all pages in section with id=about … and wordpress doesn’t do this
The WP nav menu is endlessly customizable. The ‘wp_nav_menu’ filter passes to your callback the entire menu’s HTML for you to alter as you please just before it is output to the browser. For complete control, write (or customize the default) a walker function to process each menu item in turn.
Thread Starter
oudrib
(@oudrib)
Thank you @bcworkz i will try this 🙂