WordPress.org

Forums

How to Post On-the-fly and write in DB (2 posts)

  1. soulgeek
    Member
    Posted 4 years ago #

    Folks,

    I have spend 6 days trying to understand how can i tweak WP, but all in vain.

    Requirement:

    I have written a script, which pulls data from various sources on the fly.
    So, URL Structure will be like:

    http://www.mydomain.com/findprod.php?q=paintball-mask

    And this findprod.php will use q value and pull data from other sources on the web. I want to make a Post on the Fly and then Write the post Content to Database, so that next time, if i hit the same URL (www.mydomain.com/findprod.php?q=paintball-mask), the Find Product will not be run coz that URL's Data has already been Cached. (Can W3 Cache Plugin Will do this all by its own?)

    In Other words, Purpose if to Mkae a Post on the Fly and write it to Database as a Cache.

    What i have Done:

    I have tried to use a fucntion wp_insert_post($ontheflypost) but where shall i put that function? In single.php of my Template or Where?

    global $user_ID;
    $new_post = array(
        'post_title' => 'My New Post',
        'post_content' => 'Lorem ipsum dolor sit amet...',
        'post_status' => 'publish',
        'post_date' => date('Y-m-d H:i:s'),
        'post_author' => $user_ID,
        'post_type' => 'post',
        'post_category' => array(0)
    );
    $post_id = wp_insert_post($new_post);

    If i put this snipper in function.php, where do i need to call this Function? Is it in single.php or where?

    HOw can i achieve what i am trying to do?

    Please help me out, i am Lost.

    Cheers

  2. thekoolman3
    Member
    Posted 4 years ago #

    Hello.

    I do not know PHP coding, so are you asking if you can post from a mobile device like... your cell phone? or Android media tablet ECT. (there is an app for Apple devices... so I left them out)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.