Next/Previous Links in same category

previous_post_link takes 5 params, but you use only 2 of them. Let’s take a look at other 3: in_same_term (boolean) (optional) Indicates whether previous post must be within the same taxonomy term as the current post. If set to ‘true’, only posts from the current taxonomy term will be displayed. If the post is in … Read more

Determine if a navigation item has children

You can filter wp_nav_menu_objects and add the classes in one rush. You don’t even need a custom walker for that. add_filter( ‘wp_nav_menu_objects’, ‘add_has_children_to_nav_items’ ); function add_has_children_to_nav_items( $items ) { $parents = wp_list_pluck( $items, ‘menu_item_parent’); foreach ( $items as $item ) in_array( $item->ID, $parents ) && $item->classes[] = ‘has-children’; return $items; } The class has-children will … Read more

How to set limit only on top levels of wp_nav_menu?

According to the codex, you just need to use depthparameter to display only top-level pages : <?php wp_nav_menu( array( ‘location’ => ‘your_location’, ‘depth’ => 1 ) ); ?> For more reference see this. You could also fix both of your problem by using [wp_get_nav_menu_items][2] and then using a custom loop to parse only first and … Read more

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

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