Create your own ecommerce website and start selling successfully with ShopWired today
Displaying content from a website page
Before you proceed: |
If you would like to display content from a website page on another page, then follow the instructions below.
For example, you might like to display the content from your delivery policy page on every product page on your website (which is the example we'll follow in this tutorial).
1. First, you'll need to create the website page (if it doesn't already exist).
2. You'll need to get the unique ID of the page that you have just created. Click to edit the website page and take note of the URL in your browser's address bar, which will look something like the example below.
https://v5.shopwired.co.uk/business/manage-website-page/1726 |
The ID is the number in the URL, e.g. 1726.
3. You'll need to find the twig file that relates to the website page you want to display the content on. In our example, we want to display content on the product page so we're editing product.twig.
Once you've opened the page file you'll need to locate, in the code, where you need to add the new code so that the content from the website page displays in the correct place. In our example, we are going to display the content beneath the social media sharing buttons.
4. The code to display content from a website page is shown below:
{% set embedded_page = page(1726) %} {% if embedded_page %} {{ embedded_page.title }} {{ embedded_page.content|raw }} {% endif %} |
Where you replace 1726 with the ID you got in part (2).
5. Copy this code into the twig file you've opened in (3) and you'll now have something that looks like this.
You can see the new code from lines 203 to 207.
embedded_page.title relates to the title of the page
embedded_page.content relates to the content of the page
We've applied the raw filter so that the page content outputs with its HTML tags (escaped).