Check if tag, category or author on archive.php

you can use it just like you posted which is safe and would do the job just fine: if (is_author()) { $author = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author)); } elseif (is_category()) { //this will work in categories tags or custom taxonomy $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); $current_term = get_term_by( … Read more

Custom URL parameters in template files

The global $wp_query object is not what you are looking for by the time you get to single.php. Instead use global $wp object. Try changing your code to this: global $wp; if (array_key_exists(‘myvar’, $wp->query_vars) && isset($wp->query_vars[‘myvar’])){ echo ‘custom variable recognized’; } print_r($wp->query_vars);

Menus, but not by theme location

wp_nav_menu takes an optional argument called menu, which will fetch any menu by name, slug or ID. If you just want post objects (or anything but the menu HTML), wp_get_nav_menus is the way to go. Otherwise, use wp_nav_menu. If you need it to return the menu HTML instead of echoing, there’s an argument for that … Read more

Arguments ignored/markup changed in wp_nav_menu if no menu is selected

Here’s the default usage of wp_nav_menu(): <?php $defaults = array( ‘theme_location’ => , ‘menu’ => , ‘container’ => ‘div’, ‘container_class’ => ‘menu-{menu slug}-container’, ‘container_id’ => , ‘menu_class’ => ‘menu’, ‘menu_id’ => , ‘echo’ => true, ‘fallback_cb’ => ‘wp_page_menu’, ‘before’ => , ‘after’ => , ‘link_before’ => , ‘link_after’ => , ‘items_wrap’ => ‘<ul id=\”%1$s\” class=\”%2$s\”>%3$s</ul>’, … Read more