Adding Cornerstone Content in PHP

Hi!

We have a Woocommerce site.
The shop page we want, is the list of products (that are listed by default on the shop page), with some content above, and some content below, that we want to add with cornerstone.

If we click “edit with cornerstone” it goes to cornerstone, but we cant add any content. I think is not possible to add cornerstone content on the woocommerce shop page?

We tried by inserting the [product_page id=‘xx’] shortcode into a normal cornerstone page, but the products shop process doesnt work.

So, we thought about a solution.
Create the content that we want to add on two separate pages : one for the content that goes before the shop list, and another for the content that goes below the shop list.

We don’t however, know how to add that page content into the shop php “woocommerce.php”.
Currently we are using the following:

 $id = '1860';
 $p = get_page($id);
 echo apply_filters('the_content', $p->post_content);

But the content does not has all the content that shows up when we view the actual page.
For example, it lacks the x-container, and other cornerstone related elements.

Our question is, what is the best way to include cornerstone pages content within the woocommerce shop page.

Hi there,

I suggest that you use the Global Blocks for this matter. Go to X > Global Blocks and add a Global Block of what you would do in the Cornerstone. Then keep the shortcode of the Global Block in mind:

For my case it was [cs_gb id=179].

Then you will need to install a Child Theme and use the Woocommerce actions to add that Global Block to the shop page.

For more detailed information about actions please read the article below:
https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x/208

I used this tutorial to find out what will be the best action to use. I decided to use the woocommerce_before_shop_loop action as it will render the Global Block just before the Shop Loop.

So I added the code below to the functions.php file of my Child Theme:

function shop_before_content() {
	echo do_shortcode('[cs_gb id=179]');
}
add_action('woocommerce_before_shop_loop', 'shop_before_content');
  1. I used the do_shortcode feature of the WordPress to add the Global Block shortcode.
  2. You will need to change [cs_gb id=179] in the code with your Global Block shortcode.]
  3. You can change the place of the Global Block by checking the Tutorial link and use another action which will add the Global Block to the section of the page that you want.

Thank you.

Christopher, thank you very much, that looks great. I will try it and let you know how it goes.

On behalf of my colleague, you’re welcome and we’ll await your reply. Thank you.

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