How to execute PHP code inside LiveCanvas pages
No PHP code is allowed directly into LiveCanvas pages, but you can insert ordinary WordPress shortcodes – and there’s a nice helper to make the process smoother and “live”.
This way you can have dynamic elements inside LiveCanvas pages – which to begin with are mostly a chunk of static HTML (albeit they can contain some inline JS and CSS if you wish).
How to insert Shortcodes in a LiveCanvas page
In the LiveCanvas Blocks browser open the WordPress Integration panel > then choose the Shortcode element.
This way you can use any kind of WordPress plugin which leverages shortcodes – like most WP plugins do – and to instantly preview their output without saving the page.
A special shortcode: Get Posts
In the WordPress Integration panel there is also a tool to pull data from your site/ blog: Get Posts.
Implemented by a shortcode which is directly defined by LiveCanvas, this tool will basically display a posts loop in a neat and configurable way. It has a visual interface to build custom posts queries with all the parameters offered by WordPress. You can of course pull data from custom post types, filter posts by category, author, post_id, custom fields.
The outputted post listing can be displayed as Bootstrap cards or within a plain HTML structure with configurable headings and class names, or with your own custom php callback function.
This feature has been introduced in version 1.24 and you can read more about in this post.Next Topic: Adding animations with the AOS library »