PRO - Assign X template to dynamically added page

Hi,

I’m using wp_insert_post to add few hundreds page to my Wordpress.
I previously created some templates with X that I need to assign to these new pages.
How can I do that using PHP in my import script please?

Regards

Hi @lijecreative,

Thanks for writing in.

There is no available API for that as of now. The data are stored in a post meta of a page/post and it’s a serialized data. The post meta name is _cornerstone_data, and you can use this line to get the data

$POST_ID = 782;
$data = cs_get_serialized_post_meta( $POST_ID, '_cornerstone_data', true );

or this one to update the data


$data = 'your data';
$POST_ID = 782;

cs_update_serialized_post_meta( $POST_ID, '_cornerstone_data', $data, '', false, 'cs_content_update_serialized_content' );

This is just based on the code I saw in the core, it’s up to you how you’ll handle the data after the retrieval or before updating. What you could do is, a trial and error, first, pull an existing data and observe its format (using var_dump and debugging), then use that format to build your own data. We can’t provide further support on this, I just provided this to help you or your developer to get started :slight_smile:

Thanks!

Well, the _cornerstone_ data post meta isn’t set or created when you apply an existing X template to the current page, in the admin.

The content of the page is just populated with the content of the template so I guess I must update the page content data instead.

Cornerstone template’s information are stored in the wp_posts table with cs_template as the post type. That is all I can give though because as support, we do not focus on the internal functions of the theme let alone we can give you a custom script as that is outside the scope of our support.

Thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.