Display Menu Name using wp_nav_menu

If you know the menu’s slug, then things are easier, otherwise you can use this function to get the menu at a specified location. <?php function wpse45700_get_menu_by_location( $location ) { if( empty($location) ) return false; $locations = get_nav_menu_locations(); if( ! isset( $locations[$location] ) ) return false; $menu_obj = get_term( $locations[$location], ‘nav_menu’ ); return $menu_obj; } … Read more

theme path in javascript file

What you’re looking for is wp_localize_script function. You use it like this when enqueing script wp_register_script( ‘my-script’, ‘myscript_url’ ); wp_enqueue_script( ‘my-script’ ); $translation_array = array( ‘templateUrl’ => get_stylesheet_directory_uri() ); //after wp_enqueue_script wp_localize_script( ‘my-script’, ‘object_name’, $translation_array ); In your style.js, there is going to be: var templateUrl = object_name.templateUrl; …

Display Search Result Count

If you are within the search template i.e Search query is your main query. You should then be able to get search results from global $wp_query without running an additional query. global $wp_query; echo $wp_query->found_posts.’ results found.’; Edit 1 If you have to get count out of search context. You can combine both techniques to … Read more

CSS not updating in browser when I change it

Add a random version number at the end of the css file you are attaching. If you are using ‘wp_enqueue_style‘ or wp_register_style functions, pass a random (version) number rand(111,9999) to 4th parameter. If you are attaching css as an html tag, you should add “?ver=<?php echo rand(111,999)?>” at the end of the file name. Examples … Read more

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