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

if role is logged in then do something

Something like this would be more efficient. This is basic PHP by the way, not WP specific. function add_extra_item_to_nav_menu( $items, $args ) { $roles = [ ‘administrator’ => [ //Role – slug name ‘SCHOOL_NAME-A’, //url path – appended to the end ‘ADMIN’, // can be any name – appended to SHOP NOW button ], ‘ROLEABC’ … Read more

wp_get_nav_menu_items order doesn’t work

When you look in WordPress source code, you will find reason for that. On line 538 of nav-menu.php you’ll find: if ( ARRAY_A == $args[‘output’] ) { $GLOBALS[‘_menu_item_sort_prop’] = $args[‘output_key’]; usort($items, ‘_sort_nav_menu_items’); $i = 1; foreach( $items as $k => $item ) { $items[$k]->$args[‘output_key’] = $i++; } } I didn’t check why, but it looks … Read more

I want remove last after wp_nav_menu

This will replace the last occurrence of your after string. function replace_last_nav_item($items, $args) { return substr_replace($items, ”, strrpos($items, $args->after), strlen($args->after)); } add_filter(‘wp_nav_menu’,’replace_last_nav_item’,100,2); Pure CSS will do this too: .btn_bar:last-child{display:none}

Adding html elements to wp nav menu

I made a dynamic menu using this code: //add login/logout link to menu add_filter(‘wp_nav_menu_items’, ‘wps_add_login_logout_link’, 10, 2); function wps_add_login_logout_link($items, $args) { $login = __(‘Sign in’); $logout = __(‘Sign out’); $menu_id = ’15’; $menu_id2 = ’16’; if ( ! is_user_logged_in() ) $link = ‘<a href=”‘ . site_url(‘log-in-log-out’) . ‘”>’ . $login . ‘</a>’; else $link = … Read more

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