Multi Level Bootstrap Navigation Menu in WordPress

Here some thing interesting for you STEP 1 add a script to header like below ( it’s always better go for the enqueue method . i need some one to help me with properly adding the below script in WordPress way .jquery should run before the second script> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js” type=”text/javascript”></script> <script> $(document).ready(function () { … Read more

wp_get_nav_menu_items how to exclude sub level menu items?

Think I worked it out!! I did a print_r on each $menu_item and saw there’s an array key called menu_item_parent in there. So I changed this: foreach ( (array) $menu_items as $key => $menu_item ) { $title = $menu_item->title; $url = $menu_item->url; $menu_output .= ‘<option value=”‘ . $url . ‘”>’ . $prefix . $title . … Read more

Prev/Next child navigation for current page?

All right, here it is, fully working: <?php $pagelist = get_pages(“child_of=”.$post->post_parent.”&parent=”.$post->post_parent.”&sort_column=menu_order&sort_order=asc”); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page->ID; } $current = array_search($post->ID, $pages); $prevID = $pages[$current-1]; $nextID = $pages[$current+1]; ?> <div class=”navigation”> <?php if (!empty($prevID)) { ?> <div class=”previous”> <a href=”https://wordpress.stackexchange.com/questions/54422/<?php echo get_permalink($prevID); ?>” title=”<?php echo get_the_title($prevID); ?>”>Previous</a> </div> <?php } … Read more

wp_nav_menu always falls back to a menu

wp_nav_menu() indeed tries a lot to provide you with a menu, and fallback_cb is only executed when nothing else works. From the code: If menu is provided and refers to an existing menu (looked up via wp_get_nav_menu_object(), which accepts an id, slug or name), this will be the menu Otherwise, if theme_location is set to … Read more

wp_nav_menu not appearing for a couple pages

I had the same problem, but with a newer version of WordPress (3.7.1). On pages with custom taxonomies of custom posts, the wp_nav_menu was not shown. The solution below worked for me. in functions.php of the theme: add_action( ‘pre_get_posts’, ‘my_pre_get_posts’ ); function my_pre_get_posts($query) { if ($query->get(‘post_type’) === ‘nav_menu_item’) { $query->set(‘tax_query’,”); } }

add span class inside wp_nav_menu link anchor tag

Have you tried using the before or link_before parameters in your array arguments when declaring your wp_nav_menu function? Note: use after or link_after for the opposite effect. Example, wp_nav_menu( //normal arguments here….etc ‘before’ => ‘<span class=”arrow”></span>’, //or ‘link_before’ => ‘<span class=”arrow”></span>’, ); From the Codex: $before (string) (optional) Output text before the of the link … Read more

Call custom field into menu item

This is what i have used for checking to see if the custom field is there or not. I am sure you can use it as well. <?php $custom_field = get_post_meta($post->ID, ‘Your Custom Field Name’, true); // Checks to see if there is a value in the custom field if($custom_field != ”) { echo $custom_field; … Read more