Adding an external link to wordpress menu

You’re _doing_it_wrong(). When you call wp_nav_menu(), you should be referencing theme_location, not menu. The way the custom navigation menu functionality is intended to work: The Theme registers locations for navigation menus to appear, via register_nav_menus( array( ‘location_slug’ => ‘Location Name’ ). Then the Theme instructs WordPress where to output those menus, via wp_nav_menu( array( ‘theme_location’ … Read more

exclude pages in custom menu

You probably want to explode your list of page ID’s using the explode function. Something like; <?php $exmenuitems = explode(“,”,get_option(‘exmenuitems’)); $recentPosts = new WP_Query(); $recentPosts->query (array ( ‘post__not_in’ => $exmenuitems, ‘post_type’ => ‘page’, ‘showposts’ => $menuitems )); I’d recommend using the WordPress Menu building functions and admin interface. Its much more intuitive for end users … Read more

Recent Posts widget missing current_menu_item class

The core Recent Posts Widget does not output any classes for the current post – probably because the Widget semantically is a list of posts, rather than a navigation menu, and therefore has no intended purpose to reflect current location. That said, with a bit of CSS/jQuery trickery, you could target the current post by … Read more

Edit the (automatic) HTML layout of nav menus

Update: The question was actually how to wrap the submenus, not the whole menu. Here are 2 options: using jQuery: <script type=”text/javascript”> // run this before the script that sets up the dropdowns: jQuery(document.ready(function($){ $(‘.sub-menu’).wrap(‘<div class=”dropdown”></div>’); }) </script> using PHP 5.3+ (slightly more complex option, but thought i’d post it): <?php $dom = DOMDocument::loadHTML(wp_nav_menu(array( ‘menu’ … Read more

add_filter for where statment issue

So first of all you’ll want to make sure that you want to and your WHERE clause in. posts_where will fire for (almost) every query so you want to be sure that you’re adding it to the right one. This can be done with the use of conditional tags. Note: The WHERE 1=1 is added … Read more

show current item in custom menu, when inside a custom post type

Put this in your functions.php: function additional_active_item_classes($classes = array(), $menu_item = false){ global $wp_query; if(in_array(‘current-menu-item’, $menu_item->classes)){ $classes[] = ‘current-menu-item’; } if ( $menu_item->post_name == ‘product’ && is_post_type_archive(‘product’) ) { $classes[] = ‘current-menu-item’; } if ( $menu_item->post_name == ‘product’ && is_singular(‘product’) ) { $classes[] = ‘current-menu-item’; } return $classes; } add_filter( ‘nav_menu_css_class’, ‘additional_active_item_classes’, 10, 2 ); … Read more

Automatically Display Sub Menu

If your developing this theme with your own html mark up and css then should be fairly easy… <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘menu_class’ => ‘topNav’, ‘after’ => ‘<span> </span>’ ) ); ?> You will notice this menu PHP generates a unordered list with your sub menu as a nested unordered list. See your … Read more