I have created a simple WordPress plugin that automatically sets my new sites up with the default settings that are shared across all of them.
As part of the install, it creates my Privacy Policy page. However, currently, I’m just inserting “This is the privacy policy page” for the content, since it’s just stored in a variable that I send to the wp_insert_post function. I’d like to actually insert my full, html formatted privacy policy instead of the dummy text.
I’m just looking for some ideas as to how I can do this.
Here’s the code I’m using currently for the hard coded privacy policy insert…
$my_post3 = array();
$my_post3['post_title'] = 'Privacy Policy';
$my_post3['post_content'] = 'Insert your privacy policy content here';
$my_post3['post_type'] = 'page';
//insert the default pages into the site
wp_insert_post($my_post1);
wp_insert_post($my_post2);
wp_insert_post($my_post3);
So I just need to perhaps parse an external .html or txt file and stream it into that $my_post3[‘post_content’] variable, keeping all the html formatting intact.
Any ideas?
Well, if you have the content in a file that’s accessible, you can just use
file_get_contents():That of course requires that the privacy_policy.txt file is in the same directory with your PHP script. If you have the privacy policy on another server, you can also use an url in the
file_get_contents: