WordPress.org

Ready to get started?Download WordPress

Forums

Indicate a post was posted using iphone app (4 posts)

  1. mattregister
    Member
    Posted 2 years ago #

    Is there any way to indicate that a post was posted with the iphone app? The only way a post will get published is through the normal backend with a laptop or through the iphone app. If I can find a way to make a conditional tag such as

    if "published through XML-RPC" {echo 'Published via iPhone'} ;

    The posts published through the app are going to be fast and potentially typo-prone. If I had a way of excusing that it would be great.

    Anybody have any ideas? Any help would be appreciated.

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    This is a bit of a workaround. As I understand it the app doesn't have custom fields. But you can set a custom field automatically when saving a post through XML-RPC.
    Put this in your theme's functions.php:

    function set_ios_meta($post_ID){
    if(wp_is_post_autosave($post_ID) || wp_is_post_revision($post_ID)) {
      return $post_ID;
    }
    update_post_meta($post_ID, 'ios', 'true');
    }
    add_action('xmlrpc_publish_post', 'set_ios_meta');

    To show the custom field in your theme's template files use this:

    <?php
    $meta_value = get_post_meta($post->ID, 'ios', true);
    if($meta_value != ''){
    echo 'Published via iPhone';
    }
    ?>
  3. mattregister
    Member
    Posted 2 years ago #

    That's awesome! That is the answer. Thank you much for the quick reply and the excellent answer. The site is http://kingdomdog.org

  4. keesiemeijer
    moderator
    Posted 2 years ago #

    you're welcome. Glad you got it resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic