Detect Mobile Browser using Server Side Includes (SSI)

There’s a website dedicated for open source code in various programming languages to detect mobile browsers. However they didn’t have any code to detect a mobile browser using SSI. Thats what I needed to make the HTML pages on my website mobile friendly. Using the <!--#if expr SSI conditional expression, I wrote up a small code snippet to detect the most common smart phones and set a variable when a mobile phone is detected. I use this variable in other parts of HTML to control what is show and what is not to make it suitable for a mobile browser. Continue reading

Redirect WordPress XMLRPC Clients to a Custom Post Type

Lets say you want to post from your Android or Iphone WordPress clients to a custom post type instead of the the defualt ‘post’ type. Paste the code below in your functions.php and you should be good to go 🙂

function redirect_xmlrpc_to_custom_post_type ($data, $postarr) {
    $p2_custom_post_type = 'custom_post_type'; //Change this to the custom post type you are using for your blog
    if (defined('XMLRPC_REQUEST') || defined('APP_REQUEST')) {
        $data['post_type'] = $p2_custom_post_type;
        return $data;
    return $data;

add_filter('wp_insert_post_data', 'redirect_xmlrpc_to_custom_post_type', 99, 2);

Change $p2_custom_post_type = 'custom_post_type' to the custom post type you are using for your blog.

Now I can post from my Android Phone to my custom P2 micro-blog 🙂