How to Post On-the-fly and write in DB
-
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
- The topic ‘How to Post On-the-fly and write in DB’ is closed to new replies.