get_the_title() gets printed out twice

Your conditional is always true. To understand why, consider what happens in this function when there is no post parent: function get_top_ancestor_id() { global $post; // no parent so this doesn’t run: // if($post->post_parent) { // $ancestors = array_reverse(get_post_ancestors($post->ID)); // return $ancestors[0]; // } return $post->ID; } Which simplifies to: function get_top_ancestor_id() { global $post; … Read more

Listing Child Pages in a Certain Order?

Based on your comments here is another option , using wp_list_pages and without having to work with arrays and pulling content manually, I’m leaving out a bunch of the options, just the bare essentials. <ul> <?php $priority_pages=”5,1,3,7″; wp_list_pages(array(‘include’ => $priority_pages); wp_list_pages(array(‘exclude’ => $priority_pages); ?> </ul> since, wp_list_pages, just gives you the <li> elements, you can … Read more

Custom Menus: dynamic highlighting problem with custom home link

I achieved this with some jQuery: $(“#sidebar ul li”).each(function () { if ($(this).find(“a”).attr(“href”) == window.location.href) { $(this).addClass(“current-menu-item”); } }); (My nav is in a div with the id ‘sidebar’, you will need to change the first selector). It checks if the href of the links is the same as the current URL, and if so, … Read more

add_action does not call the function

Currently it doesn’t seem to exist a filter to manage fields in the menu creation. On the other hand, what you can do is to create a new “menu walker”, to provide WordPress input fields as well as adding your own. That involves the extension of WordPress class Walker_Nav_Menu_Edit with your own code. Since the … Read more

Remove a menu sub-item

You’d want to add this code: add_action( ‘admin_menu’, ‘remove_admin_menus’, 999 ); function remove_admin_menus() { remove_submenu_page( ‘users.php’, ‘new-user-approve-admin’ ); }

Dynamic_sidebar inside wp_nav_menu

You can add extra items in menu like add_filter( ‘wp_nav_menu_items’, ‘your_custom_menu_item’, 10, 2 ); function your_custom_menu_item ( $items, $args ) { if ($args->theme_location == ‘[YOUR-MENU-LOCATION]’) { $items .= ‘–YOUR EXTRA STUFF HERE–‘; } return $items; } Hope it will help!