when creating new woocommerce shop page, should I insert all the HTML file as string directly to wp_post DB table?

EDIT
I am building a plugin that add a buttons to products that the shop owner choose by dash board.
I have that little.

I want that when a user press on the button, the page will ridirect.
In that page I want to use parts of the specific product product original page. But to make some changes like change some html.

I had tried to create the page by code, but the only succeed like that:

$title = __( ‘Bogin’ );
if ( NULL == get_page_by_title( $title ) ) {
$post_id = wp_insert_post(
array(
‘post_name’ => ‘bogin’,
‘post_title’ => $title,
‘post_content’ => “some content”,
‘post_type’ => ‘page’,
‘comment_status’ => ‘closed’,
‘ping_status’ => ‘closed’,
‘post_status’ => ‘publish’,

` )

);

the page that I want to display have the URL: www.shopurl.com/mySpecilePage/someId

and its content is a big html file.

I’m inserting such a big file as string to column page_content in wp_post table, and then when reloading the site the browser display 500 internal error. I think it because the DB crashes.

I have two solutions for that issue:
1. increase the filed size in the DB by code – it feel a bad idea.
2. insert an html page that have only one div inside it and inject content inside with jQuery or JS.

about the second how can I activate the jQuery code when the page reload ?

**EDIT – 2 – solution **

I found that if I will insert in the content filed this:

<script type=’application/javascript’>
jQuery(function(){
jQuery(“#divForInject”).load(“http://myDomain/fileToInsert.html”);
});
</script>
<div id=’divForInject’></div>

then I can put there any page I need.
I will use html that have jQuery to get the product I’d from url.

Read more here:: when creating new woocommerce shop page, should I insert all the HTML file as string directly to wp_post DB table?

Leave a Reply

Your email address will not be published. Required fields are marked *