Set page content in PHP, editable via cornerstone

Hi,

I have a loop that creates about 100 pages. I would like to set a cornerstone template or some content and then to be able to edit the page in cornerstone.

My loop looks like that:

                $new_post = array(
                'post_title' => wp_strip_all_tags(remove_accents(trim($row["nom_srubrique"]))),
                'post_content' => '',
                'post_status' => $postStatus,
                'post_author' => $userID,
                'post_type' => $postType,
                'post_parent' => $arrayIds[$pos]
            );
            $post_id = wp_insert_post($new_post);

The post_content field is empty since I don’t know how to inset a cornerstone template in here.

Can you help?

Thanks

Hi @lijecreative,

Regretfully, this particular request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your automation. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

I suggest you create a template page then check the table wp_posts and wp_postmeta in the database to get the post content and template data,

Thank you for your understanding.

I see, maybe you can help with this last question.

Sometimes when you edit a page content in plain HTML, cornerstone says the content is not compatible anymore. Where in the database can I set the page content has a cornerstone editable content?

Hi @lijecreative,

Cornerstone data is stored in wp_postmeta, so you also need to add that when adding your post.

For example for post with id-305 these are the cornerstone data.

Hi,

If I do it this way, the div classes are not the same.

The page content set sections with ID, then cornerstone creates it but the style inserted in the _cs_generated_styles meta has not the right classes.

How should I do?

I found a way :slight_smile:

Glad to hear that, cheers!

Hi! Can i ask you how did you manage to solve this?

My page is complex. It has a sidebar with custom code and widgets, a left part with a lot of sections (1/2+1/2, 1/3+2/3, …) and a header (page header, not a website header).

Instead of trying to put a CS content in the page body and playing with meta (which doesn’t work), I used a shortcode: [sidebar name=“Formation_header”]

I used the plugin “Custom Sidebars Pro” to create custom sidebars then I used “Pages In Widgets” to put the pages contents in a widget.

I created my sidebar content in a page for which I set noindex, nofollow and excluded from sitemap, with the template “no container, no header, no footer”. Then, I put this page in the sidebar. For this step, you need to use full width row without containers and section paddings.

The full content of my pages created from the loop is:

[sidebar name="Formation_header"]<div class="x-section"><div class="x-container max width"><div class="x-column x-sm x-2-3">[sidebar name="Formation_body"]</div><div class="x-column x-sm x-1-3">[sidebar name="Formation_sidebar"]</div></div></div>

Hi @lijecreative,

Thank you for sharing your solution.

Have a great day! :slight_smile:

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