There are a couple ways you can go about this. You can do as WebSon has suggested but with a different approach, you can do it via page templates, or you can do it with custom post metas. Now note, while you're doing something with "ID's," I suggest you change the navigation displayed using wp_nav_menu()
.
One method with a suggested conditional, instead of ID's.
<?php
$first_array = [ 'page1', 'page3', 'page5' ];
$second_array = [ 'page2', 'page4', 'page6' ];
$wp_nav_args = [ //your default args ];
if ( is_page($first_array ) ) {
// Change the entire array or parts of it.
$wp_nav_args = [];
}
elseif ( is_page($second_array) ) {
// Change the entire array or parts of it.
$wp_nav_args = [];
}
wp_nav_menu($wp_nav_args);
Page Templates
<?php
$wp_nav_args = [ //your default args ];
if ( is_page_template('template-menu-a') ) {
// Change the entire array or parts of it.
$wp_nav_args = [];
}
elseif ( is_page_template('template-menu-b') {
// Change the entire array or parts of it.
$wp_nav_args = [];
}
wp_nav_menu($wp_nav_args);
More complicated way, which doesn't include templates, yet is extendable.
Just wanted to share this way, as you can use this for a few other things as well, by creating custom post metas. This example shows a checkbox in the Update/Publish box.
<?php
function add_custom_meta_field() {
$post_id = get_the_ID();
if ( get_post_type( $post_id ) !== 'page' ) {
return;
}
$value = get_post_meta( $post_id, '_navigation_b', true );
?>
<div class="misc-pub-section misc-pub-section-last">
<input type="checkbox" value="1" <?php checked( $value, true, true ); ?> name="_navigation_b" id="_navigation_b" /><label for="_navigation_b"><?php _e( 'Add To Your Calendar Icons', 'navy' ); ?></label>
</div>
<?php
}
add_action( 'post_submitbox_misc_actions', 'add_custom_meta_field' );
function save_custom_meta_field() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
if ( isset( $_POST['_navigation_b'] ) ) {
update_post_meta( $post_id, '_navigation_b', $_POST['_navigation_b'] );
} else {
delete_post_meta( $post_id, '_navigation_b' );
}
}
add_action( 'save_post', 'save_custom_meta_field' );