Add Useragent to the body class?

something like this maybe: function my_class_names($classes) { $useragent = $_SERVER[‘HTTP_USER_AGENT’]; if(strchr($useragent,’Safari’)) $classes[] = ‘Safari’; // etc.. return $classes; } add_filter(‘body_class’,’my_class_names’); Edit – as per Chip’s suggestion, here’s the function using the WordPress useragents checks: function my_class_names($classes) { global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone; if($is_lynx) $classes[] = ‘lynx’; elseif($is_gecko) $classes[] = ‘gecko’; elseif($is_winIE) … Read more

why doesnt is_home() work in functions.php

At the time functions.php is included during bootup, WordPress has no idea on the contents of the query, and doesn’t know the nature of the page. is_home will return false. Wrap the code in a function and have it triggered by the wp hook, which comes after the global query object has been hydrated with … Read more

Is it possible to disable a function of a parent theme?

Only under some circumstances. If the parent theme’s functions are wrapped in function_exists conditionals then you should be able to replace them. For example: // Parent if (!function_exists(‘p_wpse_95799’)) { function p_wpse_95799() { // } } If the child theme defines a function named p_wpse_95799 then the parent function will not be used. If this is … Read more

bloginfo() vs get_option?

The two functions output exactly the same thing. From the Codex entry for get_bloginfo(): ‘name’ – Returns the “Site Title” set in Settings > General. This data is retrieved from the “blogname” record in the wp_options table. From source: case ‘name’: default: $output = get_option(‘blogname’); Neither get_bloginfo() nor bloginfo() do any sort of sanitization or … Read more

How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?

You should echo it and also you are closing your php tag improperly. View source the o/p generated to get some idea img<src=<?php echo get_template_directory_uri().”/assets/img/flexslider/flex-1.jpg”?> alt=”alternative_name”> or you can use bloginfo which is easier to remember and use (You need not echo) <img src=”<?php bloginfo(‘template_url’); ?>/assets/img/flexslider/flex-1.jpg”/>

How to add attributes to a shortcode

You just have to add another element to the array (and then output it): function btn_shortcode( $atts, $content = null ) { $a = shortcode_atts( array( ‘class’ => ‘button’, ‘href’ => ‘#’ ), $atts ); return ‘<a class=”‘ . esc_attr($a[‘class’]) . ‘” href=”‘ . esc_attr($a[‘href’]) . ‘”>’ . $content . ‘</a>’; } add_shortcode( ‘button’, ‘btn_shortcode’ … Read more