WordPress.org

Support

Support » Plugins and Hacks » Hacks » Front end post from file "outside" wordpress,

Front end post from file "outside" wordpress,

  • Hello,

    So I’ve written a json / java / backbone app that will do a couple of translations and then i need to post it to the DB…

    The thing is that the file that I have as post file stands “outside” wp which makes the front end posting a little harder…

    What i wonder is simply how I should connect to and be able to post from a file outside the WP libary but still needs to go in to the WP post table.

    Would lobe to get some help.

    Best Regards
    Grundell

Viewing 4 replies - 1 through 4 (of 4 total)
  • The best way that I can think of is to use a home page template and add your extra code to that. If your theme doesn’t have it, you can create a file called front-page.php and it will be used automatically for the sites home page layout.

    First of all Create a Page With Form for Post Values e.g. Title, Description, Category etc. and Extra Meta Data.

    Example Code ….

    $myPost = array(
        'post_title' => $_POST['postTitle'],
        'post_status' => $postStatus, //  @See http://wordpress.org/support/topic/post_status
        'post_author' => $userID, // you can set Post author ID at here eg. Current Logged in User see http://goo.gl/bsjPx
        'post_category' => array($_POST['category'])
    );
    
    // Now Insert Post Data into DB
    $postId = wp_insert_post($myPost);
    
    // for custom Meta data
    add_post_meta($postId, 'duration', mysql_real_escape_string($_POST['duration']), true);
    add_post_meta($postId, 'country', mysql_real_escape_string($_POST['country']), true);

    Finally your post has been submitted.

    There’s a chrome extension which you can use to post from anywhere on the web

    https://chrome.google.com/webstore/detail/post-to-wordpress/hhmhfcfbheceghfbfjgkjnlhooadpnej

    Might be useful, not sure it does exactly what you need though?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Front end post from file "outside" wordpress,’ is closed to new replies.