Get the children of the parent category

You can’t just pass the string “parent” to get_categories. You have to pass the ID of the parent. $categories=get_categories( array( ‘parent’ => $cat->cat_ID ) ); Notice that there are two similar but not equal “get child” parameters that you can use. child_of (integer) Display all categories that are descendants (i.e. children & grandchildren) of the … Read more

Dynamically exclude menu items from wp_nav_menu

Method 1 You can add a constructor to your custom Walker to store some additional exclusion arguments, like: class custom_nav_walker extends Walker_Nav_Menu { function __construct( $exclude = null ) { $this->exclude = $exclude; } function skip( $item ) { return in_array($item->ID, (array)$this->exclude); // or return in_array($item->title, (array)$this->exclude); // etc. } // …inside start_el, end_el if … Read more

Programmatically add a Navigation menu and menu items

I might be misunderstanding you, but why not use wp_create_nav_menu()? E.g., this is what I do to create a custom BuddyPress menu when I detect BP as active: $menuname = $lblg_themename . ‘ BuddyPress Menu’; $bpmenulocation = ‘lblgbpmenu’; // Does the menu exist already? $menu_exists = wp_get_nav_menu_object( $menuname ); // If it doesn’t exist, let’s … Read more

Navigate to an anchor on another page

Are you sure that you have placed the files in the same directory? I’ve tested the code that you have provided and it’s working. However, you could try this out (a different way of giving sections an id): If you have done this, just use the same way of linking: