• Home
  • Docs
  • About
  • Resume
  • Services
    • Testimonials
    • Leave A Testimonial
  • Stack Exchange
    • Android
      • Spanish
      • French
      • German
    • Apple
      • Spanish
      • French
      • German
    • Ask Ubuntu
      • Spanish
      • French
      • German
    • Bicycles
      • Spanish
      • French
      • German
    • Cooking
      • Spanish
      • French
      • German
    • CrossValidated
      • Spanish
      • French
      • German
    • Database Administrator
      • Spanish
      • French
      • German
    • Drupal
      • Spanish
      • French
      • German
    • Electronics
      • Spanish
      • French
      • German
    • Game Development
      • Spanish
      • French
      • German
    • Gaming
      • Spanish
      • French
      • German
    • GIS
      • Spanish
      • French
      • German
    • Home Improvement
      • Spanish
      • French
      • German
    • Mathematics
      • Spanish
      • French
      • German
    • Photography
      • Spanish
      • French
      • German
    • Physics
      • Spanish
      • French
      • German
    • Programmers
      • Spanish
      • French
      • German
    • Stack Overflow
      • Spanish
      • French
      • German
Humbug
Bah! Humbug!
Home 2010 Redirect WordPress XMLRPC Clients to a Custom Post Type
  • Email
  • Share

Redirect WordPress XMLRPC Clients to a Custom Post Type

  • 11 Comments
  • Tweet
Pratik Sinha | July 10, 2010

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 :)

Posted in Tips-N-Tricks | Tagged android, custom post type, iphone, p2, wordpress, xmlrpc | 11 Responses

  • Tweet

Logging In...

Reply Click here to cancel reply.

Sign in with Twitter Sign in with Facebook
or

  • 11 Replies
  • 11 Comments
  • 0 Tweets
  • 0 Facebook
  • 0 Pingbacks
Last reply was 208 days ago
  1. Varun
    View 573 days ago

    Cool! But is there a more maintainable way to do it? You custom changes will get wiped out in an automated upgrade and will need to be reapplied.

    Reply
    • Pratik Sinhareplied:
      View 570 days ago

      You could also use this plugin. It lets you customize themes through the wp-admin. Even if the theme updates, your customizations will not be affected.

      Reply
  2. Pratik Sinha
    View 570 days ago

    @Varun Well they won’t be because the theme for my website is a custom child theme for the hybrid wordpress theme. Infact I always run the svn trunk version of hybrid, so it updates almost every second week. Even the theme for the NSM Website is a child theme I adapted from a old theme by the same developer – Justin Tadlock.

    Reply
  3. Aaron D. Campbell
    View 470 days ago

    While the changes wouldn’t get overwritten, it only lets you use a custom post type at the expense of not being able to work with actual posts.

    Reply
    • Pratik Sinhareplied:
      View 466 days ago

      True, and I use my desktop blogging application only for my custom post types. However it should be easy to modify it to lets say make it tag based. If you have a tag “custom_post_type” then it will publish as your custom post type or as a normal post otherwise. Your comment went into the spam folder for some reason, akismet doesn’t like you :)

      Reply
  4. Xander
    View 290 days ago

    The code doesnt work anymore.
    It gives me a 500 internal error message.
    Can you update this post? You are the only one on the web with this sollution. Too bad it is outdated.

    Reply
    • Pratik Sinhareplied:
      View 273 days ago

      @Xander, the code snippet still works for me, not sure why it isn’t working for you.

      Reply
      • Xanderreplied:
        View 272 days ago

        Don’t you have a idea how this might happen ? When I use the code snippet it gives me a 500 internal server error. I have xmlrpc enabled. Do I need to do something in htacces maybe ?

        Reply
        • Pratik Sinhareplied:
          View 269 days ago

          Can you try this?

          function redirect_xmlrpc_to_custom_post_type ($data, $postarr) {
            if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) {
              $data['post_type'] = 'custom_post_type';
            }
            return $data;
          }
          
          Reply
          • Pratik Sinhareplied:
            View 269 days ago

            Ofcourse you gotta chage ‘custom_post_type’ to the post type you’re using.

          • TGreplied:
            View 208 days ago

            No its same – I got the same problem. the method doesnt work if I put this in the functions.php.

            BTW I’m using WP 3.2.1

« Previous Next »

Recommend on Google
  • RSS
  • Facebook
  • Twitter

Subscribe

Get the latest posts delivered straight to your inbox.

Chatter Away

Recently Popular

  • Make English the Default Language for Google Chrome Search
  • Kill/Quit and Restart Plasma on KDE
  • Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes
  • Bash Tricks: Split / Cut a String with Multi Character Delimiters
  • Utility to Send Commands or Data to Other Terminals (tty/pts)
  • Make English the Default Language for Mozilla Firefox Search
  • A Sample Loop in XSL, Alternative for While, For Loops
  • Bash Tricks: Split / Cut a String with Multi Character Delimiters Using AWK
  • Bash Tricks: Create variables dynamically using some eval magic
  • Makefile Tricks: Arithmetic – Addition, Subtraction, Multiplication, Division, Modulo, Comparison

Latest Tweets

  • Ruby on Rails Debugging Techniques: Nice succinct blog on ROR debugging techniques, saving it for future reference... http://t.co/36mceCNP 2 hours ago
  • Get Android Remote Notifier to work with Unity on Ubuntu Natty (11.04) and Oneiric (11.10): Ubuntu Natty onwards, ... http://t.co/c3rLfD27 3 days ago
  • Wireless Sniffer on Ubuntu Linux - Capture / Analyze Network Traffic: Jotting down an easy recipe to get a 802.11 ... http://t.co/rZqwjVE5 1 week ago
  • RT @MaheshNBhatt: Mukul Sinha from Jansangharsh Manch called to say that the police are denying the riot victims the permission to hold ... 4 months ago
  • RT @MaheshNBhatt: They have just informed me that they will court arrest and begin to fast if the Gujarat govt denies them their constit ... 4 months ago

Services Offered

  • Embedded Linux Systems and Services
  • Gateway Routers (Frontend and Backend)
  • Free and Open Source Software Solutions
  • Network Monitoring Solutions
  • Device Driver Development

Recent Comments

  • buckley commented on Utility to Send Commands or Data to Other Terminals (tty/pts)
    (1 weeks ago)
  • Arup Kumar Kabi commented on Wireless Sniffer on Ubuntu Linux - Capture / Analyze Network Traffic
    (1 weeks ago)
  • Varun V Nair commented on Wireless Sniffer on Ubuntu Linux - Capture / Analyze Network Traffic
    (1 weeks ago)
  • Ajit Bhat commented on Wireless Sniffer on Ubuntu Linux - Capture / Analyze Network Traffic
    (1 weeks ago)

Categories

  • As An Aside
  • Code-Snippets
  • Software
  • Testimonials
  • Tips-N-Tricks

Copyright © 2012 Humbug.

Powered by WordPress and Hybrid.