Bar separated navigation by extending Walker_Nav_Menu

You can use the menu order inside the item to see if it’s not first. If it isn’t have it draw the character before the anchor. class Bar_List_Walker_Nav_Menu extends Walker_Nav_Menu { private $separator = ” | “; function start_el(&$output, $item, $depth, $args) { if($item->menu_order > 1){ $output .= $this->separator; } $attributes = ! empty( $item->target … Read more

How can I disable parent menu item links?

Do not create fake URLs (#). This would be very bad for users with a screen reader: the are using a list of available links to browse your site. The same is true for javascript: links, they are not exactly elegant markup anyway. You need two steps: Mark the items with children before the walker … Read more

How to show only parents subpages of current page item in vertical menu?

Finally, I solved it myself. Here is the solution: In functions.php: function show_all_children($parent_id, $post_id, $current_level) { $top_parents = array(); $top_parents = get_post_ancestors($post_id); $top_parents[] = $post_id; $children = get_posts( array( ‘post_type’ => ‘page’ , ‘posts_per_page’ => -1 , ‘post_parent’ => $parent_id , ‘order_by’ => ‘title’ , ‘order’ => ‘ASC’ )); if (empty($children)) return; echo ‘<ul class=”children … Read more

Category menu item and its last 10 posts as sub-menu

I finally achieve it with this code in function.php // Front end only, don’t hack on the settings page if ( ! is_admin() ) { // Hook in early to modify the menu // This is before the CSS “selected” classes are calculated add_filter( ‘wp_get_nav_menu_items’, ‘display_lasts_ten_posts_for_categories_menu_item’, 10, 3 ); } // Add the ten last … Read more

Remove navigation from header in custom page template

Use a conditional tag: Codex References: Function Reference (is_page) Function Reference (Conditional Tags) You can specify the landing page by Page ID, Page Title or Page Slug. Here is an example: <?php if ( !is_page( ‘landing-page’ ) ) { wp_nav_menu( array( ‘show_home’ => ‘Home’, ‘container’ => ‘false’, ‘theme_location’ => ‘main’) ); } endif; ?> It … Read more

Can I add pages to my custom menu via script?

You can use wp_nav_menu_{$menu->slug}_items hook and add you link with a callback function, for example if your menu slug is header-menu then something like this: add_filter(‘wp_nav_menu_header-menu_items’, ‘add_my_extra_links’,10,2); function add_my_extra_links($items, $args) { $newitems=”<li><a title=”Test Link” href=”http://google.com”>Google</a></li>”; $newitems .= ‘<li><a title=”Test Link” href=”http://yahoo.com”>Yahoo</a></li>’; $newitems .= ‘<li><a title=”Test Link” href=”http://bing.com”>Bing</a></li>’; $newitems .= $items; return $newitems; } Update I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)