How to get a different mobile menu than desktop menu in the twentytwelve child theme

As recommended in a similar post: https://wordpress.stackexchange.com/a/156494/74343 1.) Create the menus as you want them, and name them as you like, as an example “mobile-menu” and “desktop-menu“. 2.) In your child theme in the header.php you could switch according to the wp_is_mobile() flag like this: if ( wp_is_mobile() ) { wp_nav_menu( array( ‘menu’ => ‘mobile-menu’ … Read more

What’s the earliest point I can get the queried object ID?

A more compact and WordPress-ish way, using url_to_postid(): function wpmp_switcher_exclusions_init() { $pid = url_to_postid( home_url( add_query_arg( array() ) ) ); if ( (int) $pid > 0 && get_post_meta( $pid, ‘_wp_page_template’, TRUE ) === ‘my-responsive-template.php’ ) { remove_action(‘init’, ‘wpmp_switcher_init’); remove_action(‘admin_menu’, ‘wpmp_switcher_admin_menu’); remove_action(‘wp_footer’, ‘wpmp_switcher_wp_footer’); remove_filter(‘stylesheet’, ‘wpmp_switcher_stylesheet’); remove_filter(‘template’, ‘wpmp_switcher_template’); remove_filter(‘option_home’, ‘wpmp_switcher_option_home_siteurl’); remove_filter(‘option_siteurl’, ‘wpmp_switcher_option_home_siteurl’); } } add_action( ‘setup_theme’, ‘wpmp_switcher_exclusions_init’ … Read more

Deactivate plugins only for mobile devices

If you deactivate a plugin, the change is stored in database, so in all subsequent access the plugin is deactivated, no matter the device used to access the site. Filtering the option Active plugin in WordPress are retrieved using wp_get_active_and_valid_plugins() function. It uses the option “active_plugins” to get the currently active plugin. All options in … Read more

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

How-to add rewrite rules to point the uploads folder to a subdomain

If you are not willing to filter only image uploads, i.e., all uploaded media will reside in the same folder/subdomain, then there’s a simple configuration solution: go to options-media.php set the Store uploads option to wp-content/uploads set the Full URL option to http://uploads.yourdomain.com create a subdomain making the uploads folder be http://uploads.yourdomain.com

How can I have two different urls for the same page that load two different templates?

You could accomplish this with a rewrite endpoint and a template filter. First, register a new rewrite endpoint for the page post type: function wpd_app_view_rewrite_endpoint() { add_rewrite_endpoint( ‘app-view’, EP_PAGES ); } add_action( ‘init’, ‘wpd_app_view_rewrite_endpoint’ ); Don’t forget to flush rewrite rules after adding this (or just visit the Permalinks > Settings page to do this … Read more

How do I make my blog iPad / iPhone / Android friendly?

I personally use the WP Touch plugin on my site. It automatically detects if the user is browsing with an iPhone (or iPad) and reformats the site into an iOS-friendly layout with touch-sensitive controls. There’s an option at the bottom for visitors to display the normal site if they want. It’s a very well-supported system, … Read more

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